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
0dbc7e6f
Commit
0dbc7e6f
authored
Sep 15, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not refresh snippet statistics on read-only instance
SnippetStatistics#refresh! may be run on a Geo secondary
parent
28aafc89
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
app/models/snippet_statistics.rb
app/models/snippet_statistics.rb
+2
-0
spec/models/snippet_statistics_spec.rb
spec/models/snippet_statistics_spec.rb
+16
-3
No files found.
app/models/snippet_statistics.rb
View file @
0dbc7e6f
...
...
@@ -34,6 +34,8 @@ class SnippetStatistics < ApplicationRecord
end
def
refresh!
return
if
Gitlab
::
Database
.
read_only?
update_commit_count
update_repository_size
update_file_count
...
...
spec/models/snippet_statistics_spec.rb
View file @
0dbc7e6f
...
...
@@ -75,15 +75,28 @@ RSpec.describe SnippetStatistics do
end
describe
'#refresh!'
do
subject
{
statistics
.
refresh!
}
it
'retrieves and saves statistic data from repository'
do
expect
(
statistics
).
to
receive
(
:update_commit_count
)
expect
(
statistics
).
to
receive
(
:update_file_count
)
expect
(
statistics
).
to
receive
(
:update_repository_size
)
expect
(
statistics
).
to
receive
(
:save!
)
subject
statistics
.
refresh!
end
context
'when the database is read-only'
do
it
'does nothing'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
expect
(
statistics
).
not_to
receive
(
:update_commit_count
)
expect
(
statistics
).
not_to
receive
(
:update_file_count
)
expect
(
statistics
).
not_to
receive
(
:update_repository_size
)
expect
(
statistics
).
not_to
receive
(
:save!
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
statistics
.
refresh!
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