Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-04-28 14:13:29 +0400
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-04-28 14:13:29 +0400
commit0b615eb0e2b5cca7685360c0cae72484741d672e (patch)
treef5f2540b9de83311b01146b6f0c2ba30f3dbda36 /app/finders/notes_finder.rb
parent7339464e7701c0778cca12c12ace83ebd8ffe2f7 (diff)
Filter out old notes in NotesFinder
Diffstat (limited to 'app/finders/notes_finder.rb')
-rw-r--r--app/finders/notes_finder.rb8
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