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
16f107cb
Commit
16f107cb
authored
May 27, 2019
by
Toon Claes
Committed by
Douglas Barbosa Alexandre
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out load_ methods and simplify condition
Don't put code in large if blocks, but do an early return instead.
parent
8ba8815c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
63 deletions
+65
-63
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+65
-63
No files found.
ee/app/models/geo_node_status.rb
View file @
16f107cb
...
@@ -145,13 +145,6 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -145,13 +145,6 @@ class GeoNodeStatus < ApplicationRecord
end
end
def
load_data_from_current_node
def
load_data_from_current_node
self
.
status_message
=
begin
HealthCheck
::
Utils
.
process_checks
([
'geo'
])
rescue
NotImplementedError
=>
e
e
.
to_s
end
latest_event
=
Geo
::
EventLog
.
latest_event
latest_event
=
Geo
::
EventLog
.
latest_event
self
.
last_event_id
=
latest_event
&
.
id
self
.
last_event_id
=
latest_event
&
.
id
self
.
last_event_date
=
latest_event
&
.
created_at
self
.
last_event_date
=
latest_event
&
.
created_at
...
@@ -175,14 +168,25 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -175,14 +168,25 @@ class GeoNodeStatus < ApplicationRecord
self
.
hashed_storage_attachments_max_id
=
Geo
::
HashedStorageAttachmentsEvent
.
maximum
(
:id
)
self
.
hashed_storage_attachments_max_id
=
Geo
::
HashedStorageAttachmentsEvent
.
maximum
(
:id
)
self
.
projects_count
=
geo_node
.
projects
.
count
self
.
projects_count
=
geo_node
.
projects
.
count
load_status_message
load_primary_data
load_primary_data
load_secondary_data
load_secondary_data
self
self
end
end
def
load_status_message
self
.
status_message
=
begin
HealthCheck
::
Utils
.
process_checks
([
'geo'
])
rescue
NotImplementedError
=>
e
e
.
to_s
end
end
def
load_primary_data
def
load_primary_data
if
Gitlab
::
Geo
.
primary?
return
unless
Gitlab
::
Geo
.
primary?
self
.
lfs_objects_count
=
LfsObject
.
syncable
.
count
self
.
lfs_objects_count
=
LfsObject
.
syncable
.
count
self
.
job_artifacts_count
=
Ci
::
JobArtifact
.
syncable
.
count
self
.
job_artifacts_count
=
Ci
::
JobArtifact
.
syncable
.
count
self
.
attachments_count
=
Upload
.
syncable
.
count
self
.
attachments_count
=
Upload
.
syncable
.
count
...
@@ -197,14 +201,13 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -197,14 +201,13 @@ class GeoNodeStatus < ApplicationRecord
self
.
wikis_checksummed_count
=
repository_verification_finder
.
count_verified_wikis
self
.
wikis_checksummed_count
=
repository_verification_finder
.
count_verified_wikis
self
.
wikis_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_wikis
self
.
wikis_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_wikis
end
end
self
.
repositories_checked_count
=
Project
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
repositories_checked_failed_count
=
Project
.
where
(
last_repository_check_failed:
true
).
count
end
end
end
def
load_secondary_data
# rubocop:disable Metrics/AbcSize
def
load_secondary_data
# rubocop:disable Metrics/AbcSize
if
Gitlab
::
Geo
.
secondary?
return
unless
Gitlab
::
Geo
.
secondary?
self
.
db_replication_lag_seconds
=
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
self
.
db_replication_lag_seconds
=
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
self
.
cursor_last_event_id
=
current_cursor_last_event_id
self
.
cursor_last_event_id
=
current_cursor_last_event_id
self
.
cursor_last_event_date
=
Geo
::
EventLog
.
find_by
(
id:
self
.
cursor_last_event_id
)
&
.
created_at
self
.
cursor_last_event_date
=
Geo
::
EventLog
.
find_by
(
id:
self
.
cursor_last_event_id
)
&
.
created_at
...
@@ -233,10 +236,10 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -233,10 +236,10 @@ class GeoNodeStatus < ApplicationRecord
self
.
repositories_checked_count
=
Geo
::
ProjectRegistry
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
repositories_checked_count
=
Geo
::
ProjectRegistry
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
repositories_checked_failed_count
=
Geo
::
ProjectRegistry
.
where
(
last_repository_check_failed:
true
).
count
self
.
repositories_checked_failed_count
=
Geo
::
ProjectRegistry
.
where
(
last_repository_check_failed:
true
).
count
end
end
end
def
load_verification_data
def
load_verification_data
if
repository_verification_enabled
return
unless
repository_verification_enabled
self
.
repositories_verified_count
=
registries_for_verified_projects
(
:repository
).
count
self
.
repositories_verified_count
=
registries_for_verified_projects
(
:repository
).
count
self
.
repositories_verification_failed_count
=
registries_for_verification_failed_projects
(
:repository
).
count
self
.
repositories_verification_failed_count
=
registries_for_verification_failed_projects
(
:repository
).
count
self
.
repositories_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:repository
).
count
self
.
repositories_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:repository
).
count
...
@@ -246,7 +249,6 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -246,7 +249,6 @@ class GeoNodeStatus < ApplicationRecord
self
.
repositories_retrying_verification_count
=
registries_retrying_verification
(
:repository
).
count
self
.
repositories_retrying_verification_count
=
registries_retrying_verification
(
:repository
).
count
self
.
wikis_retrying_verification_count
=
registries_retrying_verification
(
:wiki
).
count
self
.
wikis_retrying_verification_count
=
registries_retrying_verification
(
:wiki
).
count
end
end
end
def
current_cursor_last_event_id
def
current_cursor_last_event_id
return
unless
Gitlab
::
Geo
.
secondary?
return
unless
Gitlab
::
Geo
.
secondary?
...
...
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