Skip to content
Snippets Groups Projects
Commit f6b8db78 authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

fix metrics tagging limiting by total check date

parent 6be49cda
No related branches found
No related tags found
1 merge request!396fix metrics tagging limiting by total check date
...@@ -99,13 +99,15 @@ with audits as ( ...@@ -99,13 +99,15 @@ with audits as (
select au.* from audit.audit_log au select au.* from audit.audit_log au
inner join manuscript m on au.manuscript_id = m.id inner join manuscript m on au.manuscript_id = m.id
where m.organization_id='${orgId}' where m.organization_id='${orgId}'
and au.created between date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${endMonth} month'::interval) and au.changes->>'type' = 'PMC'
and date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${startMonth - or (
1} month'::interval) au.created between date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${endMonth} month'::interval)
and ( and date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${startMonth -
au.changes->>'status' is not null or 1} month'::interval)
au.changes->>'type' = 'PMC' or and (
au.changes::text ~* '(re-|re)tag' au.changes->>'status' is not null or
au.changes::text ~* '(re-|re)tag'
)
) )
), external as ( ), external as (
select * from audits ae where ae.user_id not in ( select * from audits ae where ae.user_id not in (
...@@ -118,12 +120,15 @@ with audits as ( ...@@ -118,12 +120,15 @@ with audits as (
from ( from (
select aa.manuscript_id, aa.manuscript_version, ab.sent, aa.created, generate_series(ab.sent, aa.created - '1 day'::interval, '1 day'::interval) as date_range select aa.manuscript_id, aa.manuscript_version, ab.sent, aa.created, generate_series(ab.sent, aa.created - '1 day'::interval, '1 day'::interval) as date_range
from ( from (
select at.manuscript_id, at.manuscript_version, min(at.created) created from audits at select * from (
where at.user_id in ( select at.manuscript_id, at.manuscript_version, min(at.created) created from audits at
select user_id from team t where t.role_name='tagger' where at.user_id in (
) select user_id from team t where t.role_name='tagger'
and at.changes->>'type' = 'PMC' )
group by at.manuscript_id, at.manuscript_version and at.changes->>'type' = 'PMC'
group by at.manuscript_id, at.manuscript_version
) am where am.created between date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${endMonth} month'::interval) and date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${startMonth -
1} month'::interval)
union union
select a.manuscript_id, a.manuscript_version, a.created created from audits a select a.manuscript_id, a.manuscript_version, a.created created from audits a
where a.user_id in ( where a.user_id in (
...@@ -132,7 +137,7 @@ with audits as ( ...@@ -132,7 +137,7 @@ with audits as (
and a.changes::text ~* '(re-|re)tag' and a.changes::text ~* '(re-|re)tag'
and a.changes->>'notes_type'='userMessage' and a.changes->>'notes_type'='userMessage'
) aa join ( ) aa join (
select att.manuscript_id, att.manuscript_version, min(att.created) sent from audits att select att.manuscript_id, att.manuscript_version, min(att.created) sent from audit.audit_log att
where att.changes->>'status' = 'tagging' and att.original_data->>'status' = 'submitted' where att.changes->>'status' = 'tagging' and att.original_data->>'status' = 'submitted'
group by att.manuscript_id, att.manuscript_version group by att.manuscript_id, att.manuscript_version
) ab on ) ab on
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment