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

Merge branch 'dev' into 'master'

fix metrics tagging limiting by total check dates

See merge request !397
parents ed0d6c3b 83b11c8e
No related branches found
No related tags found
1 merge request!397fix metrics tagging limiting by total check dates
...@@ -96,18 +96,23 @@ right join publishers p on p.user_id = created.user_id ...@@ -96,18 +96,23 @@ right join publishers p on p.user_id = created.user_id
// xml_errors, xml_tagging, xml_tagging_within_3_days, xml_tagging_within_3_days_perc // xml_errors, xml_tagging, xml_tagging_within_3_days, xml_tagging_within_3_days_perc
const metrics = await knex.raw(` const metrics = await knex.raw(`
with audits as ( with audits as (
select au.* from audit.audit_log au
inner join manuscript m on au.manuscript_id = m.id
where m.organization_id='${orgId}'
and au.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)
and (
au.changes->>'status' is not null or
au.changes::text ~* '(re-|re)tag'
)
), tag_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.changes->>'type' = 'PMC' and au.changes->>'type' = 'PMC'
or ( and au.user_id in (
au.created between date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${endMonth} month'::interval) select user_id from team t where t.role_name='tagger'
and date_trunc('month', current_date AT TIME ZONE 'Europe/London' - '${startMonth -
1} month'::interval)
and (
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 (
...@@ -120,14 +125,8 @@ with audits as ( ...@@ -120,14 +125,8 @@ 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 * from ( select * from tag_audits at
select at.manuscript_id, at.manuscript_version, min(at.created) created from audits at where at.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 -
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
) 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) 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
......
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