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
28aafc89
Commit
28aafc89
authored
Sep 15, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not refresh project statistics on read-only instance
ProjectStatistics#refresh! may be run on a Geo secondary
parent
152b0cd9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
app/models/project_statistics.rb
app/models/project_statistics.rb
+2
-0
spec/models/project_statistics_spec.rb
spec/models/project_statistics_spec.rb
+17
-0
No files found.
app/models/project_statistics.rb
View file @
28aafc89
...
...
@@ -37,6 +37,8 @@ class ProjectStatistics < ApplicationRecord
end
def
refresh!
(
only:
[])
return
if
Gitlab
::
Database
.
read_only?
COLUMNS_TO_REFRESH
.
each
do
|
column
,
generator
|
if
only
.
empty?
||
only
.
include?
(
column
)
public_send
(
"update_
#{
column
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
...
...
spec/models/project_statistics_spec.rb
View file @
28aafc89
...
...
@@ -201,6 +201,23 @@ RSpec.describe ProjectStatistics do
statistics
.
refresh!
(
only:
[
:commit_count
])
end
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_repository_size
)
expect
(
statistics
).
not_to
receive
(
:update_wiki_size
)
expect
(
statistics
).
not_to
receive
(
:update_lfs_objects_size
)
expect
(
statistics
).
not_to
receive
(
:update_snippets_size
)
expect
(
statistics
).
not_to
receive
(
:save!
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
statistics
.
refresh!
end
end
end
describe
'#update_commit_count'
do
...
...
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