diff --git a/app/contexts/notes/load_context.rb b/app/contexts/notes/load_context.rb index c89a7d1..c026fc5 100644 --- a/app/contexts/notes/load_context.rb +++ b/app/contexts/notes/load_context.rb @@ -8,24 +8,25 @@ module Notes @notes = case target_type - when "commit" - then project.commit_notes(project.commit(target_id)).fresh.limit(20) - when "snippet" - then project.snippets.find(target_id).notes - when "wall" - then project.common_notes.order("created_at DESC").fresh.limit(50) + when "commit" + project.commit_notes(project.commit(target_id)).fresh.limit(20) when "issue" - then project.issues.find(target_id).notes.inc_author.order("created_at DESC").limit(20) + project.issues.find(target_id).notes.inc_author.fresh.limit(20) when "merge_request" - then project.merge_requests.find(target_id).notes.inc_author.order("created_at DESC").limit(20) + project.merge_requests.find(target_id).notes.inc_author.fresh.limit(20) + when "snippet" + project.snippets.find(target_id).notes.fresh + when "wall" + # this is the only case, where the order is DESC + project.common_notes.order("created_at DESC").limit(50) when "wiki" - then project.wikis.reverse.map {|w| w.notes.fresh }.flatten[0..20] + project.wikis.reverse.map {|w| w.notes.fresh }.flatten[0..20] end @notes = if last_id - @notes.where("id > ?", last_id) + @notes.where("id < ?", last_id) elsif first_id - @notes.where("id < ?", first_id) + @notes.where("id > ?", first_id) else @notes end diff --git a/app/models/note.rb b/app/models/note.rb index 4c46c7d..9aad894 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -36,7 +36,7 @@ class Note < ActiveRecord::Base scope :today, where("created_at >= :date", date: Date.today) 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") + scope :fresh, order("created_at ASC") scope :inc_author_project, includes(:project, :author) scope :inc_author, includes(:author) -- libgit2 0.21.2