Mercurial > hg > soundsoftware-site
comparison app/helpers/activities_helper.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | eb168c1e9553 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # encoding: utf-8 | |
2 # | |
3 # Redmine - project management software | |
4 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
5 # | |
6 # This program is free software; you can redistribute it and/or | |
7 # modify it under the terms of the GNU General Public License | |
8 # as published by the Free Software Foundation; either version 2 | |
9 # of the License, or (at your option) any later version. | |
10 # | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU General Public License for more details. | |
15 # | |
16 # You should have received a copy of the GNU General Public License | |
17 # along with this program; if not, write to the Free Software | |
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
1 | 19 |
2 module ActivitiesHelper | 20 module ActivitiesHelper |
3 | 21 |
4 def date_of_event(e) | 22 def date_of_event(e) |
5 if e.respond_to? :updated_at | 23 if e.respond_to? :updated_at |
145 insthash = institutions.compact.sort.group_by { |i| i } | 163 insthash = institutions.compact.sort.group_by { |i| i } |
146 insthash = insthash.merge(insthash) { |k,v| v.length } | 164 insthash = insthash.merge(insthash) { |k,v| v.length } |
147 threshold = insthash.values.sort.last(count).first | 165 threshold = insthash.values.sort.last(count).first |
148 insthash.keys.select { |k| insthash[k] >= threshold }.sample(count) | 166 insthash.keys.select { |k| insthash[k] >= threshold }.sample(count) |
149 end | 167 end |
168 | |
169 def sort_activity_events(events) | |
170 events_by_group = events.group_by(&:event_group) | |
171 sorted_events = [] | |
172 events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each do |event| | |
173 if group_events = events_by_group.delete(event.event_group) | |
174 group_events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each_with_index do |e, i| | |
175 sorted_events << [e, i > 0] | |
176 end | |
177 end | |
178 end | |
179 sorted_events | |
180 end | |
150 | 181 |
151 end | 182 end |