recent radio button
This commit is contained in:
parent
977fe73073
commit
24f04c0a61
6 changed files with 54 additions and 21 deletions
|
@ -24,6 +24,7 @@ class Note < ActiveRecord::Base
|
|||
|
||||
scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
|
||||
scope :since, lambda { |day| where("created_at >= :date", :date => (day)) }
|
||||
scope :fresh, order("created_at DESC")
|
||||
|
||||
mount_uploader :attachment, AttachmentUploader
|
||||
end
|
||||
|
|
|
@ -126,6 +126,34 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def heads
|
||||
@heads ||= repo.heads
|
||||
end
|
||||
|
||||
def fresh_commits
|
||||
commits = heads.map do |h|
|
||||
repo.commits(h.name, 10)
|
||||
end.flatten.uniq { |c| c.id }
|
||||
|
||||
commits.sort! do |x, y|
|
||||
y.committed_date <=> x.committed_date
|
||||
end
|
||||
|
||||
commits[0..10]
|
||||
end
|
||||
|
||||
def commits_since(date)
|
||||
commits = heads.map do |h|
|
||||
repo.log(h.name, nil, :since => date)
|
||||
end.flatten.uniq { |c| c.id }
|
||||
|
||||
commits.sort! do |x, y|
|
||||
y.committed_date <=> x.committed_date
|
||||
end
|
||||
|
||||
commits
|
||||
end
|
||||
|
||||
def tree(fcommit, path = nil)
|
||||
fcommit = commit if fcommit == :head
|
||||
tree = fcommit.tree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue