Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-04-24 19:06:31 +0400
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-04-24 19:06:31 +0400
commit63b58b9491badf4fe5fa79a32c6ad77be2bf3c25 (patch)
tree7dccb301891f4d9336a2dafe1c902b273d33b6a3 /app/models/network
parent75fbdc40eb6c46a5a1a5d95a314dad0b3eeda299 (diff)
Reducing database access.
Diffstat (limited to 'app/models/network')
-rw-r--r--app/models/network/graph.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index 0fe7765b9ea..ea7d188cc38 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -2,7 +2,7 @@ require "grit"
module Network
class Graph
- attr_reader :days, :commits, :map
+ attr_reader :days, :commits, :map, :notes
def self.max_count
@max_count ||= 650
@@ -16,10 +16,19 @@ module Network
@commits = collect_commits
@days = index_commits
+ @notes = collect_notes
end
protected
+ def collect_notes
+ h = Hash.new(0)
+ @project.notes.where('noteable_type = ?' ,"Commit").group('notes.commit_id').select('notes.commit_id, count(notes.id) as note_count').each do |item|
+ h[item["commit_id"]] = item["note_count"]
+ end
+ h
+ end
+
# Get commits from repository
#
def collect_commits