Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 198ad6b

Browse files
committed
refine ucb audit reset
1 parent 145aff4 commit 198ad6b

File tree

5 files changed

+99
-5
lines changed

5 files changed

+99
-5
lines changed

src-admintool/queries/audit_ucb_query.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,34 @@ def get_sql
2424
case
2525
when a.status in ('size-mismatch','digest-mismatch') then 'Audit Failed'
2626
when ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) and o.modified > date_add(now(), interval -#{@mindays} day) then 'Reset Later'
27-
when ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) then 'Reset Needed'
27+
when a.status = 'verified' and ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) then 'Reset Needed'
2828
when a.status = 'verified' then 'Audited'
2929
else 'In Progress'
3030
end as category,
3131
case
3232
when a.status in ('size-mismatch','digest-mismatch') then 'FAIL'
3333
when ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) and o.modified > date_add(now(), interval -#{@mindays} day) then 'INFO'
34-
when ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) then 'WARN'
34+
when a.status = 'verified' and ifnull(verified, o.modified) < date_add(o.modified, interval #{@mindays} day) then 'WARN'
3535
when a.status = 'verified' then 'PASS'
3636
else 'INFO'
3737
end as status
3838
from
3939
inv.inv_objects o
40-
left join
41-
inv.inv_audits a on a.inv_object_id = o.id and a.inv_node_id = 16 /*sdsc node*/
40+
right join
41+
inv.inv_audits a
42+
on
43+
a.inv_object_id = o.id
44+
and
45+
a.inv_node_id = 16 /*sdsc node*/
4246
where
4347
o.inv_owner_id=14 /*ucb owner*/
4448
and
4549
o.modified > date_add(now(), interval -#{@days.to_i} day)
4650
group by
4751
o.id,
4852
o.ark,
49-
o.modified
53+
o.modified,
54+
a.status
5055
order by
5156
o.modified desc
5257
;

src-admintool/web/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ <h3>Audit Status</h3>
346346
<ul>
347347
<li class="graph"><a href="{{ADMINTOOL_HOME}}?path=audit_status">Audit - Irregular Status</a></li>
348348
<li class="graph"><a href="{{ADMINTOOL_HOME}}?path=audit_ucb">Audit - New UCB Content</a></li>
349+
<li class="graph"><a href="{{COLLADMIN_HOME}}?path=audit_ucb_reset">Audit - Reset New UCB Content</a></li>
349350
</ul>
350351
</div>
351352

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'action'
4+
5+
# Collection Admin Task class - see config/actions.yml for description
6+
class UCBAuditResetAction < AdminAction
7+
def get_title
8+
"UCB Audit Reset"
9+
end
10+
11+
def table_headers
12+
%w[ObjectID Ark Modified Status]
13+
end
14+
15+
def table_types
16+
%w[objidlist ark datetime status]
17+
end
18+
19+
def table_rows(_body)
20+
sql = %{
21+
select distinct
22+
o.id, o.ark, o.modified, 'PASS' as status
23+
from
24+
inv.inv_objects o
25+
inner join
26+
inv.inv_audits a
27+
on
28+
a.inv_object_id = o.id
29+
and
30+
a.inv_node_id = 16 /*sdsc node*/
31+
where
32+
o.inv_owner_id=14 /*ucb owner*/
33+
and
34+
o.modified > date_add(now(), interval -7 day)
35+
and
36+
ifnull(verified, o.modified) < date_add(o.modified, interval 1 day)
37+
and
38+
o.modified < date_add(now(), interval -1 day)
39+
and
40+
a.status = 'verified'
41+
order by o.modified
42+
limit 2
43+
;
44+
}
45+
data = MerrittQuery.new(@config).run_query(sql)
46+
data.each do |r|
47+
objid = r[0]
48+
MerrittQuery.new(@config).run_update(
49+
%(
50+
update
51+
inv_audits
52+
set
53+
verified = null,
54+
status = 'unknown'
55+
where
56+
inv_object_id = ?
57+
and
58+
inv_node_id = ?
59+
),
60+
[objid, 16],
61+
'Audit reset for object'
62+
)
63+
end
64+
data
65+
end
66+
67+
def perform_action
68+
convert_json_to_table({}.to_json)
69+
end
70+
71+
def has_table
72+
true
73+
end
74+
75+
def init_status
76+
:PASS
77+
end
78+
79+
end

src-colladmin/config/actions.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,14 @@ storage-clear-audit-batch:
681681
This function clears all audit batches older than a specified amount of time.
682682
documentation: |
683683
SQL: UPDATE inv_audits SET status='unknown', verified=null
684+
audit_ucb_reset:
685+
link-title: Reset Audit Status for new UCB content
686+
class: UCBAuditResetAction
687+
category: Audit
688+
sensitivity: reversible change
689+
testing: manual
690+
description: |
691+
After 1 (1 or 2) days, trigger an immediate re-audit of new UCB content.
684692
storage-retry-audit-status:
685693
link-title: Trigger an audit retry for all audit records with a specific status
686694
class: StorageAction

src-colladmin/lambda_function.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
require_relative 'actions/consistency_report_cleanup_action'
3131
require_relative 'actions/lambda_tag_action'
3232
require_relative 'actions/system_state_action'
33+
require_relative 'actions/ucb_audit_reset_action'
3334
require 'yaml'
3435

3536
# Handle GET or POST event structures pass in via the ALB

0 commit comments

Comments
 (0)