-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24f58b7
commit 5188efb
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters