Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
0b615eb0
Commit
0b615eb0
authored
Apr 28, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter out old notes in NotesFinder
parent
7339464e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
app/finders/notes_finder.rb
app/finders/notes_finder.rb
+7
-1
spec/finders/notes_finder_spec.rb
spec/finders/notes_finder_spec.rb
+7
-0
No files found.
app/finders/notes_finder.rb
View file @
0b615eb0
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
spec/finders/notes_finder_spec.rb
View file @
0b615eb0
...
...
@@ -27,5 +27,12 @@ describe NotesFinder do
params
=
{
target_id:
commit
.
id
,
target_type:
'invalid'
}
expect
{
NotesFinder
.
new
.
execute
(
project
,
user
,
params
)
}.
to
raise_error
(
'invalid target_type'
)
end
it
'filters out old notes'
do
note2
.
update_attribute
(
:updated_at
,
2
.
hours
.
ago
)
params
=
{
target_id:
commit
.
id
,
target_type:
'commit'
,
last_fetched_at:
1
.
hour
.
ago
}
notes
=
NotesFinder
.
new
.
execute
(
project
,
user
,
params
)
notes
.
should
eq
([
note1
])
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment