diff options
author | Sato Hiroyuki <sathiroyuki@gmail.com> | 2013-04-24 15:06:31 +0000 |
---|---|---|
committer | Sato Hiroyuki <sathiroyuki@gmail.com> | 2013-04-24 15:06:31 +0000 |
commit | 63b58b9491badf4fe5fa79a32c6ad77be2bf3c25 (patch) | |
tree | 7dccb301891f4d9336a2dafe1c902b273d33b6a3 /app/models/network | |
parent | 75fbdc40eb6c46a5a1a5d95a314dad0b3eeda299 (diff) | |
download | gitlab-ce-63b58b9491badf4fe5fa79a32c6ad77be2bf3c25.tar.gz |
Reducing database access.
Diffstat (limited to 'app/models/network')
-rw-r--r-- | app/models/network/graph.rb | 11 |
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 |