From 5188efbb0dec5e78a3bcb4f895ee93b88a7869f1 Mon Sep 17 00:00:00 2001 From: Terry Brady Date: Wed, 1 May 2024 14:08:00 -0700 Subject: [PATCH] obsolete container reports --- src-admintool/config/reports.yml | 9 ++++ src-admintool/queries/obsolete_query.rb | 67 +++++++++++++++++++++++++ src-admintool/web/index.html | 1 + 3 files changed, 77 insertions(+) create mode 100644 src-admintool/queries/obsolete_query.rb diff --git a/src-admintool/config/reports.yml b/src-admintool/config/reports.yml index 54a697a..2b39b02 100644 --- a/src-admintool/config/reports.yml +++ b/src-admintool/config/reports.yml @@ -682,6 +682,15 @@ object_mult_coll: description: | Enumerate objects that have been assigned to multiple Merritt collections. Objects residing in multiple collections is a legacy Merritt feature. +obsolete: + link-title: Obosolete Container Objects + breadcrumb: bp_obj + class: ObsoleteQuery + category: admin obj + description: | + List obsolete Collection and Owner Objects + report-datatypes: + - aggrole admin_obj: link-title: Merritt Admin Objects with a Specific Role breadcrumb: bp_obj diff --git a/src-admintool/queries/obsolete_query.rb b/src-admintool/queries/obsolete_query.rb new file mode 100644 index 0000000..e8477ef --- /dev/null +++ b/src-admintool/queries/obsolete_query.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +# Query class - see config/reports.yml for description +class ObsoleteQuery < AdminQuery + def get_title + 'Obsolete Container Report' + end + + def get_sql + %{ + select + 'Owner' category, + own.id, + '' mnemonic, + own.name, + o.created, + case + when o.created > date_add(now(), interval -1 month) then 'PASS' + when o.created > date_add(now(), interval -1 year) then 'INFO' + else 'WARN' + end status + from + inv.inv_owners own + inner join inv.inv_objects o + on own.inv_object_id = o.id + where + not exists ( + select 1 + from inv.inv_objects o + where + o.inv_owner_id=own.id + ) + union + select + 'Collection' category, + c.id, + c.mnemonic, + c.name, + o.created, + case + when o.created > date_add(now(), interval -1 month) then 'PASS' + when o.created > date_add(now(), interval -1 year) then 'INFO' + else 'WARN' + end status + from + inv.inv_collections c + inner join inv.inv_objects o + on c.inv_object_id = o.id + where + not exists ( + select 1 + from inv.inv_collections_inv_objects icio + where + icio.inv_collection_id = c.id + ) + ; + } + end + + def get_headers(_results) + ['Category', 'Id', 'Mnemonic', 'Name', 'Created', 'Status'] + end + + def get_types(_results) + ['', '', 'mnemonic', 'name', 'datetime', 'status'] + end +end diff --git a/src-admintool/web/index.html b/src-admintool/web/index.html index 4c29ae6..7f63005 100644 --- a/src-admintool/web/index.html +++ b/src-admintool/web/index.html @@ -301,6 +301,7 @@

Objects Special Cases