diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-04-28 12:13:29 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-04-28 12:13:29 +0200 |
commit | 0b615eb0e2b5cca7685360c0cae72484741d672e (patch) | |
tree | f5f2540b9de83311b01146b6f0c2ba30f3dbda36 /app/finders | |
parent | 7339464e7701c0778cca12c12ace83ebd8ffe2f7 (diff) | |
download | gitlab-ce-0b615eb0e2b5cca7685360c0cae72484741d672e.tar.gz |
Filter out old notes in NotesFinder
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/notes_finder.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index 4e80bd81757..38d78f3a2d5 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -1,9 +1,12 @@ class NotesFinder + FETCH_OVERLAP = 5.seconds + def execute(project, current_user, params) target_type = params[:target_type] target_id = params[:target_id] + last_fetched_at = params.fetch(:last_fetched_at) - case target_type + notes = case target_type when "commit" project.notes.for_commit_id(target_id).not_inline.fresh when "issue" @@ -15,5 +18,8 @@ class NotesFinder else raise 'invalid target_type' end + + # Use overlapping intervals to avoid worrying about race conditions + notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP) end end |