354 |
354 |
@date_from = Date.civil(@year, @month, 1)
|
355 |
355 |
@date_to = @date_from >> 1
|
356 |
356 |
end
|
|
357 |
|
|
358 |
if params[:from] and params[:to]
|
|
359 |
@date_from = Date.parse(params[:from])
|
|
360 |
@date_to = Date.parse(params[:to])
|
|
361 |
@year = @date_to.year
|
|
362 |
@month = @date_to.month
|
|
363 |
end
|
|
364 |
|
|
365 |
if params[:user]
|
|
366 |
@only = User.find_by_login(params[:user])
|
|
367 |
end
|
357 |
368 |
|
358 |
369 |
@event_types = %w(issues news files documents changesets wiki_pages messages)
|
359 |
370 |
@event_types.delete('wiki_pages') unless @project.wiki
|
... | ... | |
366 |
377 |
# default events if none is specified in parameters
|
367 |
378 |
@scope = (@event_types - %w(wiki_pages messages))if @scope.empty?
|
368 |
379 |
|
369 |
|
@events = []
|
|
380 |
@events = []
|
370 |
381 |
|
371 |
382 |
if @scope.include?('issues')
|
372 |
|
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
|
373 |
|
@events += @project.issues_status_changes(@date_from, @date_to)
|
|
383 |
if @only
|
|
384 |
@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] )
|
|
385 |
else
|
|
386 |
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
|
|
387 |
end
|
|
388 |
if @only
|
|
389 |
@events += @project.issues_status_changes2(@date_from, @date_to, @only.id)
|
|
390 |
else
|
|
391 |
@events += @project.issues_status_changes(@date_from, @date_to)
|
|
392 |
end
|
374 |
393 |
end
|
375 |
394 |
|
376 |
395 |
if @scope.include?('news')
|
377 |
|
@events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
|
|
396 |
if @only
|
|
397 |
@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 )
|
|
398 |
else
|
|
399 |
@events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
|
|
400 |
end
|
378 |
401 |
end
|
379 |
402 |
|
380 |
403 |
if @scope.include?('files')
|
381 |
|
@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 )
|
|
404 |
if @only
|
|
405 |
@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 )
|
|
406 |
else
|
|
407 |
@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 )
|
|
408 |
end
|
382 |
409 |
end
|
383 |
410 |
|
384 |
411 |
if @scope.include?('documents')
|
385 |
|
@events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
|
386 |
|
@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 )
|
|
412 |
if @only
|
|
413 |
@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 )
|
|
414 |
else
|
|
415 |
@events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
|
|
416 |
@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 )
|
|
417 |
end
|
387 |
418 |
end
|
388 |
419 |
|
389 |
420 |
if @scope.include?('wiki_pages')
|
... | ... | |
393 |
424 |
"#{WikiContent.versioned_table_name}.id"
|
394 |
425 |
joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
395 |
426 |
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
|
396 |
|
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
|
427 |
if @only
|
|
428 |
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ? AND #{WikiContent.versioned_table_name}.author_id = ?",
|
|
429 |
@project.id, @date_from, @date_to, @only.id]
|
|
430 |
else
|
|
431 |
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
397 |
432 |
@project.id, @date_from, @date_to]
|
|
433 |
end
|
398 |
434 |
|
399 |
435 |
@events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
|
400 |
436 |
end
|
401 |
437 |
|
402 |
438 |
if @scope.include?('changesets')
|
403 |
|
@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])
|
|
439 |
if @only
|
|
440 |
@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])
|
|
441 |
else
|
|
442 |
@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])
|
|
443 |
end
|
404 |
444 |
end
|
405 |
445 |
|
406 |
446 |
if @scope.include?('messages')
|