Mercurial > hg > soundsoftware-site
changeset 1205:adb5f38f6ab7 cannam
Pick up activity date from various different methods
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Wed, 23 Jan 2013 12:00:09 +0000 |
parents | 74ad60b807ae |
children | c63e31776f92 d6d53a77f058 |
files | app/helpers/activities_helper.rb config/locales/en.yml |
diffstat | 2 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/app/helpers/activities_helper.rb Wed Jan 23 11:47:09 2013 +0000 +++ b/app/helpers/activities_helper.rb Wed Jan 23 12:00:09 2013 +0000 @@ -1,6 +1,20 @@ module ActivitiesHelper + def date_of_event(e) + if e.respond_to? :updated_at + e.updated_at + elsif e.respond_to? :updated_on + e.updated_on + elsif e.respond_to? :created_on + e.created_on + elsif e.respond_to? :committed_on + e.committed_on + else + nil + end + end + def busy_projects(events, count) # Score each project for which there are any events, by giving @@ -12,14 +26,16 @@ events.each do |e| if e.respond_to?(:project) p = e.project - d = if e.respond_to? :updated_at then e.updated_at else e.updated_on end - dd = Date.parse d.to_s - age = Date.today - dd - score = (age < 14 ? 15-age : 1) - if projhash.key? p - projhash[p] += score - else - projhash[p] = score + d = date_of_event e + if !d.nil? + dd = Date.parse d.to_s + age = Date.today - dd + score = (age < 14 ? 15-age : 1) + if projhash.key? p + projhash[p] += score + else + projhash[p] = score + end end end end
--- a/config/locales/en.yml Wed Jan 23 11:47:09 2013 +0000 +++ b/config/locales/en.yml Wed Jan 23 12:00:09 2013 +0000 @@ -497,6 +497,7 @@ label_projects_more: More projects label_project_tags_all: Popular tags label_projects_busy: Busy projects + label_projects_mature: Mature projects label_institutions_busy: Active institutions label_managers: Managed by label_issue: Issue