aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-01 20:41:20 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-01 20:41:20 +0100
commit3fa08e707fbc7899c0964bef4b501e137991d838 (patch)
treee62ea50be011e3740be47f9186a0c4740d2b2dc2 /app
parentbd095418b1a0ee8c667a54d4f6dfb7d9c86f66b6 (diff)
downloadgovuk-mini-environment-admin-3fa08e707fbc7899c0964bef4b501e137991d838.tar
govuk-mini-environment-admin-3fa08e707fbc7899c0964bef4b501e137991d838.tar.gz
Add a basic description method to GovukGuix::DataSnapshot
This is for use when rendering these in a view.
Diffstat (limited to 'app')
-rw-r--r--app/models/govuk_guix/data_snapshot.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/govuk_guix/data_snapshot.rb b/app/models/govuk_guix/data_snapshot.rb
index ec40cc4..bdfcd7e 100644
--- a/app/models/govuk_guix/data_snapshot.rb
+++ b/app/models/govuk_guix/data_snapshot.rb
@@ -40,4 +40,22 @@ class GovukGuix::DataSnapshot < ApplicationRecord
foreign_key: 'govuk_guix_revision_commit_hash'
)
belongs_to :backend, polymorphic: true, optional: true
+
+ def description
+ extracts_by_database = manifest['extracts']
+
+ dates = extracts_by_database.flat_map do |_, extracts|
+ extracts.map do |extract|
+ extract['datetime']
+ end
+ end
+
+ all_services = extracts_by_database.flat_map do |_, extracts|
+ extracts.map do |extract|
+ extract['services']
+ end
+ end
+
+ "#{dates.uniq.join(', ')}: #{all_services.join(', ')}"
+ end
end