diff options
Diffstat (limited to 'app/finders/notes_finder.rb')
-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 |