diff options
author | Christopher Baines <mail@cbaines.net> | 2018-06-01 20:41:20 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2018-06-01 20:41:20 +0100 |
commit | 3fa08e707fbc7899c0964bef4b501e137991d838 (patch) | |
tree | e62ea50be011e3740be47f9186a0c4740d2b2dc2 /app | |
parent | bd095418b1a0ee8c667a54d4f6dfb7d9c86f66b6 (diff) | |
download | govuk-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.rb | 18 |
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 |