Feature #3099 » activity_always-r3.4.patch
| app/controllers/activities_controller.rb | ||
|---|---|---|
| 27 | 27 |
begin; @date_to = params[:from].to_date + 1; rescue; end |
| 28 | 28 |
end |
| 29 | 29 | |
| 30 |
@date_to ||= User.current.today + 1 |
|
| 31 |
@date_from = @date_to - @days |
|
| 32 | 30 |
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
| 33 | 31 |
if params[:user_id].present? |
| 34 | 32 |
@author = User.active.find(params[:user_id]) |
| ... | ... | |
| 53 | 51 |
end |
| 54 | 52 |
end |
| 55 | 53 | |
| 54 |
@date_to ||= User.current.today + 1 |
|
| 55 |
@date_from = @date_to |
|
| 56 | ||
| 57 |
# Expand to empty activity period |
|
| 58 |
@activity_before = last_activity(@date_to) |
|
| 59 |
if ! @activity_before.nil? |
|
| 60 |
@date_from = @date_to - (((@date_to - @activity_before.to_date - 1) / @days).to_i + 1 ) * @days |
|
| 61 |
@activity_before = last_activity(@date_from - 1) |
|
| 62 |
if ! @activity_before.nil? |
|
| 63 |
@date_from = @date_from - (((@date_from - @activity_before.to_date - 1) / @days).to_i) * @days |
|
| 64 |
end |
|
| 65 |
end |
|
| 66 | ||
| 67 |
@activity_after = next_activity(@date_to) |
|
| 68 |
if @activity_after.nil? |
|
| 69 |
@date_to = Date.today + 1 |
|
| 70 |
else |
|
| 71 |
@date_to = @date_to + (((@activity_after.to_date - @date_to) / @days).to_i) * @days |
|
| 72 |
end |
|
| 73 | ||
| 56 | 74 |
events = @activity.events(@date_from, @date_to) |
| 57 | 75 | |
| 58 | 76 |
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language]) |
| ... | ... | |
| 87 | 105 |
rescue ActiveRecord::RecordNotFound |
| 88 | 106 |
render_404 |
| 89 | 107 |
end |
| 108 | ||
| 109 |
def last_activity(to=nil) |
|
| 110 |
Redmine::Activity::Fetcher.new(User.current, :project => @project, |
|
| 111 |
:with_subprojects => @with_subprojects, |
|
| 112 |
:author => @author). |
|
| 113 |
events(nil, to, :last_by_project => true).map{|e| e[1]}.sort.last
|
|
| 114 |
end |
|
| 115 | ||
| 116 |
def next_activity(from=nil) |
|
| 117 |
Redmine::Activity::Fetcher.new(User.current, :project => @project, |
|
| 118 |
:with_subprojects => @with_subprojects, |
|
| 119 |
:author => @author). |
|
| 120 |
events(from, nil, :next_by_project => true).map{|e| e[1]}.sort.first
|
|
| 121 |
end |
|
| 90 | 122 |
end |
| app/views/activities/index.html.erb | ||
|---|---|---|
| 1 | 1 |
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2> |
| 2 |
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
|
|
| 2 |
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_from), :end => format_date(@date_to-1)) unless @events_by_day.empty? %></p>
|
|
| 3 | 3 | |
| 4 | 4 |
<div id="activity"> |
| 5 | 5 |
<% @events_by_day.keys.sort.reverse.each do |day| %> |
| ... | ... | |
| 25 | 25 |
<ul class="pages"> |
| 26 | 26 |
<li class="previous page"> |
| 27 | 27 |
<%= link_to("\xc2\xab " + l(:label_previous),
|
| 28 |
{:params => request.query_parameters.merge(:from => @date_to - @days - 1)},
|
|
| 29 |
:title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1)),
|
|
| 30 |
:accesskey => accesskey(:previous)) %> |
|
| 28 |
{:params => request.query_parameters.merge(:from => @date_from - 1)},
|
|
| 29 |
:title => l(:label_date_from_to, :start => format_date(@date_from - @days), :end => format_date(@date_from - 1)),
|
|
| 30 |
:accesskey => accesskey(:previous)) unless @activity_before.nil? %>
|
|
| 31 | 31 |
</li><% unless @date_to > User.current.today %><li class="next page"> |
| 32 | 32 |
<%= link_to(l(:label_next) + " \xc2\xbb", |
| 33 | 33 |
{:params => request.query_parameters.merge(:from => @date_to + @days - 1)},
|
| config/locales/en.yml | ||
|---|---|---|
| 258 | 258 |
field_downloads: Downloads |
| 259 | 259 |
field_author: Author |
| 260 | 260 |
field_created_on: Created |
| 261 |
field_last_activity: Last activity |
|
| 261 | 262 |
field_updated_on: Updated |
| 262 | 263 |
field_closed_on: Closed |
| 263 | 264 |
field_field_format: Format |
| config/locales/pt-BR.yml | ||
|---|---|---|
| 224 | 224 |
field_downloads: Downloads |
| 225 | 225 |
field_author: Autor |
| 226 | 226 |
field_created_on: Criado em |
| 227 |
field_last_activity: Última atividade |
|
| 227 | 228 |
field_updated_on: Alterado em |
| 228 | 229 |
field_field_format: Formato |
| 229 | 230 |
field_is_for_all: Para todos os projetos |
| lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | ||
|---|---|---|
| 55 | 55 | |
| 56 | 56 |
scope = (provider_options[:scope] || self) |
| 57 | 57 | |
| 58 |
if from && to |
|
| 59 |
scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to)
|
|
| 60 |
end |
|
| 58 |
scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from
|
|
| 59 |
scope = scope.where("#{provider_options[:timestamp]} <= ?", to) if to
|
|
| 61 | 60 | |
| 62 | 61 |
if options[:author] |
| 63 | 62 |
return [] if provider_options[:author_key].nil? |
| ... | ... | |
| 78 | 77 |
scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
| 79 | 78 |
end |
| 80 | 79 | |
| 80 |
if options[:next_by_project] |
|
| 81 |
scope = scope.group("projects.id").minimum(provider_options[:timestamp])
|
|
| 82 |
end |
|
| 83 | ||
| 84 |
if options[:last_by_project] |
|
| 85 |
scope = scope.group("projects.id").maximum(provider_options[:timestamp])
|
|
| 86 |
end |
|
| 87 | ||
| 81 | 88 |
scope.to_a |
| 82 | 89 |
end |
| 83 | 90 |
end |
| lib/redmine/activity/fetcher.rb | ||
|---|---|---|
| 85 | 85 |
def events(from = nil, to = nil, options={})
|
| 86 | 86 |
e = [] |
| 87 | 87 |
@options[:limit] = options[:limit] |
| 88 |
@options[:last_by_project] = options[:last_by_project] if options[:last_by_project] |
|
| 89 |
@options[:next_by_project] = options[:next_by_project] if options[:next_by_project] |
|
| 88 | 90 | |
| 89 | 91 |
@scope.each do |event_type| |
| 90 | 92 |
constantized_providers(event_type).each do |provider| |
| ... | ... | |
| 92 | 94 |
end |
| 93 | 95 |
end |
| 94 | 96 | |
| 95 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
|
|
| 97 |
if options[:last_by_project] |
|
| 98 |
e.sort! |
|
| 99 |
elsif options[:next_by_project] |
|
| 100 |
e.sort! {|a,b| b <=> a}
|
|
| 101 |
else |
|
| 102 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
|
|
| 96 | 103 | |
| 97 |
if options[:limit] |
|
| 98 |
e = e.slice(0, options[:limit]) |
|
| 104 |
if options[:limit] |
|
| 105 |
e = e.slice(0, options[:limit]) |
|
| 106 |
end |
|
| 99 | 107 |
end |
| 100 | 108 |
e |
| 101 | 109 |
end |
- « Previous
- 1
- 2
- Next »