Patch #248 ยป activities_byuser.patch
| app/models/project.rb (working copy) | ||
|---|---|---|
|
id, from, to+1])
|
||
|
end
|
||
|
# Return all issues status changes for the project between the 2 given dates
|
||
|
def issues_status_changes2(from, to, user)
|
||
|
Journal.find(:all, :include => [:issue, :details, :user],
|
||
|
:conditions => ["#{Journal.table_name}.journalized_type = 'Issue'" +
|
||
|
" AND #{Issue.table_name}.project_id = ?" +
|
||
|
" AND #{Journal.table_name}.user_id = ?" +
|
||
|
" AND #{JournalDetail.table_name}.prop_key = 'status_id'" +
|
||
|
" AND #{Journal.table_name}.created_on BETWEEN ? AND ?",
|
||
|
id, user, from, to+1])
|
||
|
end
|
||
|
# returns latest created projects
|
||
|
# non public projects will be returned only if user is a member of those
|
||
|
def self.latest(user=nil, count=5)
|
||
| app/controllers/projects_controller.rb (working copy) | ||
|---|---|---|
|
@date_from = Date.civil(@year, @month, 1)
|
||
|
@date_to = @date_from >> 1
|
||
|
end
|
||
|
if params[:from] and params[:to]
|
||
|
@date_from = Date.parse(params[:from])
|
||
|
@date_to = Date.parse(params[:to])
|
||
|
@year = @date_to.year
|
||
|
@month = @date_to.month
|
||
|
end
|
||
|
if params[:user]
|
||
|
@only = User.find_by_login(params[:user])
|
||
|
end
|
||
|
|
||
|
@event_types = %w(issues news files documents changesets wiki_pages messages)
|
||
|
@event_types.delete('wiki_pages') unless @project.wiki
|
||
| ... | ... | |
|
# default events if none is specified in parameters
|
||
|
@scope = (@event_types - %w(wiki_pages messages))if @scope.empty?
|
||
|
|
||
|
@events = []
|
||
|
@events = []
|
||
|
|
||
|
if @scope.include?('issues')
|
||
|
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
|
||
|
@events += @project.issues_status_changes(@date_from, @date_to)
|
||
|
if @only
|
||
|
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=? and #{Issue.table_name}.assigned_to_id =?", @date_from, @date_to, @only.id] )
|
||
|
else
|
||
|
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
|
||
|
end
|
||
|
if @only
|
||
|
@events += @project.issues_status_changes2(@date_from, @date_to, @only.id)
|
||
|
else
|
||
|
@events += @project.issues_status_changes(@date_from, @date_to)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if @scope.include?('news')
|
||
|
@events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
|
||
|
if @only
|
||
|
@events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=? and #{News.table_name}.author_id =?", @date_from, @date_to, @only.id], :include => :author )
|
||
|
else
|
||
|
@events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if @scope.include?('files')
|
||
|
@events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
|
||
|
if @only
|
||
|
@events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=? AND #{Attachment.table_name}.author_id =?", @project.id, @date_from, @date_to, @only.id], :include => :author )
|
||
|
else
|
||
|
@events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if @scope.include?('documents')
|
||
|
@events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
|
||
|
@events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
|
||
|
if @only
|
||
|
@events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=? AND #{Attachment.table_name}.author_id =?", @project.id, @date_from, @date_to, @only.id], :include => :author )
|
||
|
else
|
||
|
@events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
|
||
|
@events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if @scope.include?('wiki_pages')
|
||
| ... | ... | |
|
"#{WikiContent.versioned_table_name}.id"
|
||
|
joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
||
|
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
|
||
|
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
||
|
if @only
|
||
|
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ? AND #{WikiContent.versioned_table_name}.author_id = ?",
|
||
|
@project.id, @date_from, @date_to, @only.id]
|
||
|
else
|
||
|
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
||
|
@project.id, @date_from, @date_to]
|
||
|
end
|
||
|
@events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
|
||
|
end
|
||
|
if @scope.include?('changesets')
|
||
|
@events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ?", @project.id, @date_from, @date_to])
|
||
|
if @only
|
||
|
@events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ? AND #{Changeset.table_name}.committer = ?", @project.id, @date_from, @date_to, @only.login])
|
||
|
else
|
||
|
@events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ?", @project.id, @date_from, @date_to])
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if @scope.include?('messages')
|
||