Commit 5e50859a authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

Merge branch 'dev' into 'master'

#1231

See merge request !413
parents 970b861e 29b6e585
......@@ -95,23 +95,18 @@ right join publishers p on p.user_id = created.user_id
// xml_review_within_3_days, xml_review_within_3_days_perc, published, ncbi_ready_median, external_qa
// xml_errors, xml_tagging, xml_tagging_within_3_days, xml_tagging_within_3_days_perc
const metrics = await knex.raw(`
with audits as (
with external 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'
)
), external as (
select * from audits ae where ae.user_id not in (
and au.user_id not in (
select user_id from team t where t.role_name='admin'
)
and ae.changes->>'status' in ('xml-review', 'xml-triage', 'repo-ready')
and ae.original_data->>'status' = 'xml-qa'
and au.changes->>'status' in ('xml-review', 'xml-triage', 'repo-ready')
and au.original_data->>'status' = 'xml-qa'
), tag_diffs as (
select manuscript_id, manuscript_version, tagged_date, sum(case when extract ('ISODOW' from date_range) < 6 then 1 else 0 end) as diff
from (
......@@ -183,21 +178,15 @@ order by top.mth desc
static async weeklyMetrics(orgId) {
const metrics = await knex.raw(`
with audits as (
with external 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('week', current_date AT TIME ZONE 'Europe/London') + -4 * '1 week'::interval and current_timestamp AT TIME ZONE 'Europe/London'
and (
au.changes->>'status' is not null or
au.changes->>'type' = 'PMC' or
au.changes::text ~* '(re-|re)tag'
)
), external as (
select * from audits ae where ae.user_id not in (
and au.user_id not in (
select user_id from team t where t.role_name='admin'
)
and ae.changes->>'status' in ('xml-review', 'xml-triage', 'repo-ready')
and ae.original_data->>'status' = 'xml-qa'
and au.changes->>'status' in ('xml-review', 'xml-triage', 'repo-ready')
and au.original_data->>'status' = 'xml-qa'
)
select display_mth, submitted, xml_review, published, external_qa, xml_tagging, xml_errors
from (
......
Markdown is supported
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