Remove similar code on GeoNodeStatus model

parent bac2eb4b
......@@ -28,12 +28,7 @@ class GeoNodeStatus
end
def repositories_synced_count
@repositories_synced_count ||=
if restricted_project_ids
Geo::ProjectRegistry.synced.where(project_id: restricted_project_ids).count
else
Geo::ProjectRegistry.synced.count
end
@repositories_synced_count ||= project_registries.synced.count
end
def repositories_synced_count=(value)
......@@ -45,12 +40,7 @@ class GeoNodeStatus
end
def repositories_failed_count
@repositories_failed_count ||=
if restricted_project_ids
Geo::ProjectRegistry.failed.where(project_id: restricted_project_ids).count
else
Geo::ProjectRegistry.failed.count
end
@repositories_failed_count ||= project_registries.failed.count
end
def repositories_failed_count=(value)
......@@ -141,6 +131,15 @@ class GeoNodeStatus
end
end
def project_registries
@project_registries ||=
if restricted_project_ids
Geo::ProjectRegistry.where(project_id: restricted_project_ids)
else
Geo::ProjectRegistry.all
end
end
def restricted_project_ids
return @restricted_project_ids if defined?(@restricted_project_ids)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment