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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
65998716
Commit
65998716
authored
Oct 18, 2019
by
Brian Kabiro
Committed by
Nick Thomas
Oct 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if mapping is empty before caching
- check if mapping is empty before calling `write_multiple` - add spec
parent
1044e5d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
changelogs/unreleased/28211-check-if-mapping-is-empty-before-caching.yml
...leased/28211-check-if-mapping-is-empty-before-caching.yml
+5
-0
lib/gitlab/discussions_diff/file_collection.rb
lib/gitlab/discussions_diff/file_collection.rb
+3
-1
spec/lib/gitlab/discussions_diff/file_collection_spec.rb
spec/lib/gitlab/discussions_diff/file_collection_spec.rb
+8
-0
No files found.
changelogs/unreleased/28211-check-if-mapping-is-empty-before-caching.yml
0 → 100644
View file @
65998716
---
title
:
Check if mapping is empty before caching in File Collections
merge_request
:
18290
author
:
briankabiro
type
:
performance
lib/gitlab/discussions_diff/file_collection.rb
View file @
65998716
...
...
@@ -27,12 +27,14 @@ module Gitlab
# - The cache content is not updated (there's no need to do so)
def
load_highlight
ids
=
highlightable_collection_ids
return
if
ids
.
empty?
cached_content
=
read_cache
(
ids
)
uncached_ids
=
ids
.
select
.
each_with_index
{
|
_
,
i
|
cached_content
[
i
].
nil?
}
mapping
=
highlighted_lines_by_ids
(
uncached_ids
)
HighlightCache
.
write_multiple
(
mapping
)
HighlightCache
.
write_multiple
(
mapping
)
if
mapping
.
any?
diffs
=
diff_files_indexed_by_id
.
values_at
(
*
ids
)
...
...
spec/lib/gitlab/discussions_diff/file_collection_spec.rb
View file @
65998716
...
...
@@ -40,6 +40,14 @@ describe Gitlab::DiscussionsDiff::FileCollection do
subject
.
load_highlight
end
it
'does not write cache for empty mapping'
do
allow
(
subject
).
to
receive
(
:highlighted_lines_by_ids
).
and_return
([])
expect
(
Gitlab
::
DiscussionsDiff
::
HighlightCache
).
not_to
receive
(
:write_multiple
)
subject
.
load_highlight
end
it
'does not write cache for resolved notes'
do
diff_note_a
.
update_column
(
:resolved_at
,
Time
.
now
)
...
...
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