diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-30 08:32:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-30 08:32:31 +0000 |
commit | db5bd2b2de4733b3c900468edf4eb35896e4f723 (patch) | |
tree | d6f86917faf3374f1a878f2566857b57b19852d8 /app/helpers/my_helper.rb | |
parent | f7782c46480f8d5ab995c988ea265d12eb7ad0a9 (diff) | |
download | redmine-db5bd2b2de4733b3c900468edf4eb35896e4f723.tar.gz redmine-db5bd2b2de4733b3c900468edf4eb35896e4f723.zip |
My page - Spent time: configurable number of days to display (#8761).
git-svn-id: http://svn.redmine.org/redmine/trunk@15942 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/my_helper.rb')
-rw-r--r-- | app/helpers/my_helper.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb index d8fe9f5eb..20abc5f3c 100644 --- a/app/helpers/my_helper.rb +++ b/app/helpers/my_helper.rb @@ -45,8 +45,9 @@ module MyHelper return end + settings = user.pref.my_page_settings(block) begin - render(:partial => "my/blocks/#{block}", :locals => {:user => user}) + render(:partial => "my/blocks/#{block}", :locals => {:user => user, :settings => settings}) rescue ActionView::MissingTemplate Rails.logger.warn("Template missing for block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences") return nil @@ -107,13 +108,18 @@ module MyHelper to_a end - def timelog_items - TimeEntry. - where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, User.current.today - 6, User.current.today). + def timelog_items(settings) + days = settings[:days].to_i + days = 7 if days < 1 || days > 365 + + entries = TimeEntry. + where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, User.current.today - (days - 1), User.current.today). joins(:activity, :project). references(:issue => [:tracker, :status]). includes(:issue => [:tracker, :status]). order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC"). to_a + + return entries, days end end |