修改最近一个月时间跨度

当前日期延生到上月的当天
This commit is contained in:
huang 2015-07-24 09:47:28 +08:00
parent 2fca0f4441
commit e5801338d6
1 changed files with 2 additions and 2 deletions

View File

@ -628,7 +628,7 @@ update
def graph_author_commits_per_month(repository)
@date_to = Date.today
@date_from = @date_to << 1
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
commits_by_author = Changeset.count(:all, :group => :committer,
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40)
@ -664,7 +664,7 @@ update
def author_commits_six_month(repository)
@date_to = Date.today
@date_from = @date_to << 6
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
commits_by_author = Changeset.count(:all, :group => :committer,
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40)