Skip to content

Commit

Permalink
obsolete container reports
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed May 1, 2024
1 parent 24f58b7 commit 5188efb
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src-admintool/config/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 67 additions & 0 deletions src-admintool/queries/obsolete_query.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src-admintool/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ <h3>Objects Special Cases</h3>
<div class="nav_section nav_merritt_internals">
<h2>Merritt Internals</h2>
<ul>
<li class="graph"><a class="json" href="{{ADMINTOOL_HOME}}?path=obsolete">Obsolete Container and Owner Objects</a></li>
<li class="graph"><a class="json" href="{{ADMINTOOL_HOME}}?path=admin_obj_agg">Merritt Admin Objects Count</a></li>
<li class="coll"><a class="json" href="{{ADMINTOOL_HOME}}?path=admin_coll">Collections Table Special Cases</a></li>
<li class="config"><a href="{{COLLADMIN_HOME}}?path=instances">Merritt Servers</a></li>
Expand Down

0 comments on commit 5188efb

Please sign in to comment.