added sprint 6 indicators to monitor db

This commit is contained in:
Antonis Lempesis 2022-02-18 17:11:23 +02:00 committed by dimitrispie
parent 58c59f46eb
commit 87c91f70a2
2 changed files with 187 additions and 166 deletions

View File

@ -31,17 +31,6 @@ join datasource d on d.id = ri.collectedfrom
where pidtype='Digital Object Identifier' and d.name ='Crossref') tmp where pidtype='Digital Object Identifier' and d.name ='Crossref') tmp
on tmp.id=p.id; on tmp.id=p.id;
create table indi_pub_gold_oa stored as parquet as
select distinct p.id, coalesce(gold_oa, 0) as gold_oa
from publication p
left outer join (
select p.id, 1 as gold_oa
from publication p
join result_instance ri on ri.id = p.id
join datasource on datasource.id = ri.hostedby
where datasource.id like '%doajarticles%') tmp
on p.id= tmp.id;
---- Sprint 2 ---- ---- Sprint 2 ----
create table indi_result_has_cc_licence stored as parquet as create table indi_result_has_cc_licence stored as parquet as
select distinct r.id, (case when lic='' or lic is null then 0 else 1 end) as has_cc_license select distinct r.id, (case when lic='' or lic is null then 0 else 1 end) as has_cc_license
@ -144,16 +133,6 @@ join stats_ext.plan_s_jn ps where (ps.issn_print=d.issn_printed and ps.issn_onli
and (ps.journal_is_in_doaj=false and ps.journal_is_oa=false)) tmp and (ps.journal_is_in_doaj=false and ps.journal_is_oa=false)) tmp
on pd.id=tmp.id; on pd.id=tmp.id;
create table indi_is_gold_oa stored as parquet as
(select distinct pd.id, coalesce(gold_oa, 0) as gold_oa
from publication_datasources pd
left outer join (
select pd.id, 1 as gold_oa from publication_datasources pd
join datasource d on d.id=pd.datasource
join stats_ext.plan_s_jn ps on (ps.issn_print=d.issn_printed or ps.issn_online=d.issn_online)
where ps.journal_is_in_doaj is true or ps.journal_is_oa is true) tmp
on pd.id=tmp.id);
create table indi_pub_in_transformative stored as parquet as create table indi_pub_in_transformative stored as parquet as
select distinct pd.id, coalesce(is_transformative, 0) as is_transformative select distinct pd.id, coalesce(is_transformative, 0) as is_transformative
from publication pd from publication pd
@ -180,180 +159,213 @@ create table indi_result_no_of_copies stored as parquet as
select id, count(id) as number_of_copies from result_instance group by id; select id, count(id) as number_of_copies from result_instance group by id;
---- Sprint 6 ---- ---- Sprint 6 ----
create table indi_pub_gold_oa_new stored as parquet as create table indi_pub_gold_oa stored as parquet as
WITH gold_oa AS (SELECT issn_l, journal_is_in_doaj,journal_is_oa, issn_1 as issn WITH gold_oa AS (
FROM stats_ext.oa_journals SELECT issn_l, journal_is_in_doaj,journal_is_oa, issn_1 as issn
WHERE issn_1 != "" FROM stats_ext.oa_journals
UNION ALL WHERE issn_1 != ""
SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_2 as issn UNION ALL
FROM stats_ext.oa_journals SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_2 as issn
WHERE issn_2 != "" ), FROM stats_ext.oa_journals
issn AS (SELECT * FROM WHERE issn_2 != "" ),
(SELECT id, issn_printed as issn issn AS (
FROM datasource WHERE issn_printed IS NOT NULL SELECT * FROM
UNION (SELECT id, issn_printed as issn
SELECT id, issn_online as issn FROM datasource WHERE issn_printed IS NOT NULL
FROM datasource WHERE issn_online IS NOT NULL) as issn UNION
WHERE LENGTH(issn) > 7) SELECT id, issn_online as issn
FROM datasource WHERE issn_online IS NOT NULL) as issn
WHERE LENGTH(issn) > 7)
SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
FROM publication_datasources pd FROM publication_datasources pd
LEFT OUTER JOIN LEFT OUTER JOIN (
(SELECT pd.id, 1 as is_gold FROM publication_datasources pd SELECT pd.id, 1 as is_gold FROM publication_datasources pd
JOIN issn on issn.id=pd.datasource JOIN issn on issn.id=pd.datasource
JOIN gold_oa on issn.issn = gold_oa.issn) tmp JOIN gold_oa on issn.issn = gold_oa.issn) tmp ON pd.id=tmp.id;
ON pd.id=tmp.id;
create table indi_datasets_gold_oa_new stored as parquet as create table indi_datasets_gold_oa stored as parquet as
WITH gold_oa AS (SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_1 as issn WITH gold_oa AS (
FROM stats_ext.oa_journals SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_1 as issn
WHERE issn_1 != "" FROM stats_ext.oa_journals
UNION WHERE issn_1 != ""
ALL SELECT issn_l,journal_is_in_doaj,journal_is_oa,issn_2 as issn UNION
FROM stats_ext.oa_journals ALL SELECT issn_l,journal_is_in_doaj,journal_is_oa,issn_2 as issn
WHERE issn_2 != "" ), FROM stats_ext.oa_journals
issn AS (SELECT * WHERE issn_2 != "" ),
FROM (SELECT id,issn_printed as issn issn AS (
FROM datasource WHERE issn_printed IS NOT NULL SELECT *
UNION FROM (
SELECT id, issn_online as issn SELECT id,issn_printed as issn
FROM datasource FROM datasource
WHERE issn_online IS NOT NULL ) as issn WHERE issn_printed IS NOT NULL
WHERE LENGTH(issn) > 7) UNION
SELECT id, issn_online as issn
FROM datasource
WHERE issn_online IS NOT NULL ) as issn
WHERE LENGTH(issn) > 7)
SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
FROM dataset_datasources pd FROM dataset_datasources pd
LEFT OUTER JOIN LEFT OUTER JOIN (
(SELECT pd.id, 1 as is_gold FROM dataset_datasources pd SELECT pd.id, 1 as is_gold FROM dataset_datasources pd
JOIN issn on issn.id=pd.datasource JOIN issn on issn.id=pd.datasource
JOIN gold_oa on issn.issn = gold_oa.issn) tmp JOIN gold_oa on issn.issn = gold_oa.issn) tmp ON pd.id=tmp.id;
ON pd.id=tmp.id;
create table indi_software_gold_oa_new stored as parquet as create table indi_software_gold_oa stored as parquet as
WITH gold_oa AS (SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_1 as issn WITH gold_oa AS (
FROM stats_ext.oa_journals SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_1 as issn
WHERE issn_1 != "" FROM stats_ext.oa_journals
UNION WHERE issn_1 != ""
ALL SELECT issn_l,journal_is_in_doaj,journal_is_oa,issn_2 as issn UNION
FROM stats_ext.oa_journals ALL SELECT issn_l,journal_is_in_doaj,journal_is_oa,issn_2 as issn
WHERE issn_2 != "" ), FROM stats_ext.oa_journals
issn AS (SELECT * WHERE issn_2 != "" ),
FROM (SELECT id,issn_printed as issn issn AS (
FROM datasource WHERE issn_printed IS NOT NULL SELECT *
UNION FROM (
SELECT id, issn_online as issn SELECT id,issn_printed as issn
FROM datasource FROM datasource
WHERE issn_online IS NOT NULL ) as issn WHERE issn_printed IS NOT NULL
WHERE LENGTH(issn) > 7) UNION
SELECT id, issn_online as issn
FROM datasource
WHERE issn_online IS NOT NULL ) as issn
WHERE LENGTH(issn) > 7)
SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
FROM software_datasources pd FROM software_datasources pd
LEFT OUTER JOIN LEFT OUTER JOIN (
(SELECT pd.id, 1 as is_gold FROM software_datasources pd SELECT pd.id, 1 as is_gold FROM software_datasources pd
JOIN issn on issn.id=pd.datasource JOIN issn on issn.id=pd.datasource
JOIN gold_oa on issn.issn = gold_oa.issn) tmp JOIN gold_oa on issn.issn = gold_oa.issn) tmp ON pd.id=tmp.id;
ON pd.id=tmp.id;
create table indi_org_findable stored as parquet as create table indi_org_findable stored as parquet as
with result_with_pid as with result_with_pid as (
(select ro.organization organization, count(distinct rp.id) no_result_with_pid from result_organization ro select ro.organization organization, count(distinct rp.id) no_result_with_pid from result_organization ro
join result_pids rp on rp.id=ro.id join result_pids rp on rp.id=ro.id
group by ro.organization), group by ro.organization),
result_has_abstract as result_has_abstract as (
(select ro.organization organization, count(distinct rp.id) no_result_with_abstract from result_organization ro select ro.organization organization, count(distinct rp.id) no_result_with_abstract from result_organization ro
join result rp on rp.id=ro.id where rp.abstract=true join result rp on rp.id=ro.id where rp.abstract=true
group by ro.organization), group by ro.organization),
allresults as (select organization, count(distinct id) no_allresults from result_organization allresults as (
group by organization), select organization, count(distinct id) no_allresults from result_organization
result_with_pid_share as( group by organization),
select allresults.organization, result_with_pid.no_result_with_pid/allresults.no_allresults pid_share result_with_pid_share as (
from allresults select allresults.organization, result_with_pid.no_result_with_pid/allresults.no_allresults pid_share
join result_with_pid on result_with_pid.organization=allresults.organization), from allresults
result_with_abstract_share as( join result_with_pid on result_with_pid.organization=allresults.organization),
select allresults.organization, result_has_abstract.no_result_with_abstract/allresults.no_allresults abstract_share result_with_abstract_share as (
from allresults select allresults.organization, result_has_abstract.no_result_with_abstract/allresults.no_allresults abstract_share
join result_has_abstract on result_has_abstract.organization=allresults.organization) from allresults
join result_has_abstract on result_has_abstract.organization=allresults.organization)
select allresults.organization, coalesce((pid_share+abstract_share)/2,pid_share) org_findable select allresults.organization, coalesce((pid_share+abstract_share)/2,pid_share) org_findable
from allresults from allresults
join result_with_pid_share on result_with_pid_share.organization=allresults.organization join result_with_pid_share on result_with_pid_share.organization=allresults.organization
left outer join ( left outer join (
select organization, abstract_share from result_with_abstract_share select organization, abstract_share from result_with_abstract_share) tmp on tmp.organization=allresults.organization;
)tmp
on tmp.organization=allresults.organization;
create table indi_org_openess stored as parquet as create table indi_org_openess stored as parquet as
WITH datasets_oa as ( WITH datasets_oa as (
SELECT ro.organization, count(dg.id) no_oadatasets FROM indi_datasets_gold_oa_new dg SELECT ro.organization, count(dg.id) no_oadatasets FROM indi_datasets_gold_oa_new dg
join openaire_prod_stats.result_organization ro on dg.id=ro.id join openaire_prod_stats.result_organization ro on dg.id=ro.id
join openaire_prod_stats.dataset ds on dg.id=ds.id join openaire_prod_stats.dataset ds on dg.id=ds.id
WHERE dg.is_gold=1 WHERE dg.is_gold=1
group by ro.organization), group by ro.organization),
software_oa as ( software_oa as (
SELECT ro.organization, count(dg.id) no_oasoftware FROM indi_software_gold_oa_new dg SELECT ro.organization, count(dg.id) no_oasoftware FROM indi_software_gold_oa_new dg
join openaire_prod_stats.result_organization ro on dg.id=ro.id join openaire_prod_stats.result_organization ro on dg.id=ro.id
join openaire_prod_stats.software ds on dg.id=ds.id join openaire_prod_stats.software ds on dg.id=ds.id
WHERE dg.is_gold=1 WHERE dg.is_gold=1
group by ro.organization), group by ro.organization),
pubs_oa as ( pubs_oa as (
SELECT ro.organization, count(dg.id) no_oapubs FROM indi_pub_gold_oa_new dg SELECT ro.organization, count(dg.id) no_oapubs FROM indi_pub_gold_oa_new dg
join openaire_prod_stats.result_organization ro on dg.id=ro.id join openaire_prod_stats.result_organization ro on dg.id=ro.id
join openaire_prod_stats.publication ds on dg.id=ds.id join openaire_prod_stats.publication ds on dg.id=ds.id
where dg.is_gold=1 where dg.is_gold=1
group by ro.organization), group by ro.organization),
allpubs as ( allpubs as (
SELECT ro.organization organization, count(ro.id) no_allpubs FROM result_organization ro SELECT ro.organization organization, count(ro.id) no_allpubs FROM result_organization ro
join openaire_prod_stats.publication ps on ps.id=ro.id join openaire_prod_stats.publication ps on ps.id=ro.id
group by ro.organization), group by ro.organization),
alldatasets as ( alldatasets as (
SELECT ro.organization organization, count(ro.id) no_alldatasets FROM result_organization ro SELECT ro.organization organization, count(ro.id) no_alldatasets FROM result_organization ro
join openaire_prod_stats.dataset ps on ps.id=ro.id join openaire_prod_stats.dataset ps on ps.id=ro.id
group by ro.organization), group by ro.organization),
allsoftware as ( allsoftware as (
SELECT ro.organization organization, count(ro.id) no_allsoftware FROM result_organization ro SELECT ro.organization organization, count(ro.id) no_allsoftware FROM result_organization ro
join openaire_prod_stats.software ps on ps.id=ro.id join openaire_prod_stats.software ps on ps.id=ro.id
group by ro.organization), group by ro.organization),
allpubsshare as ( allpubsshare as (
select pubs_oa.organization, pubs_oa.no_oapubs/allpubs.no_allpubs p from allpubs select pubs_oa.organization, pubs_oa.no_oapubs/allpubs.no_allpubs p from allpubs
join pubs_oa on allpubs.organization=pubs_oa.organization), join pubs_oa on allpubs.organization=pubs_oa.organization),
alldatasetssshare as ( alldatasetssshare as (
select datasets_oa.organization, datasets_oa.no_oadatasets/alldatasets.no_alldatasets c select datasets_oa.organization, datasets_oa.no_oadatasets/alldatasets.no_alldatasets c
from alldatasets from alldatasets
join datasets_oa on alldatasets.organization=datasets_oa.organization), join datasets_oa on alldatasets.organization=datasets_oa.organization),
allsoftwaresshare as ( allsoftwaresshare as (
select software_oa.organization, software_oa.no_oasoftware/allsoftware.no_allsoftware s select software_oa.organization, software_oa.no_oasoftware/allsoftware.no_allsoftware s
from allsoftware from allsoftware
join software_oa on allsoftware.organization=software_oa.organization) join software_oa on allsoftware.organization=software_oa.organization)
select allpubsshare.organization, coalesce((c+p+s)/3, p) org_openess FROM allpubsshare select allpubsshare.organization, coalesce((c+p+s)/3, p) org_openess
left outer join (select organization,c from FROM allpubsshare
alldatasetssshare) tmp left outer join (
on tmp.organization=allpubsshare.organization select organization,c from
left outer join (select organization,s from alldatasetssshare) tmp on tmp.organization=allpubsshare.organization
allsoftwaresshare) tmp1 left outer join (
on tmp1.organization=allpubsshare.organization; select organization,s from allsoftwaresshare) tmp1 on tmp1.organization=allpubsshare.organization;
create table indi_pub_hybrid_oa_with_cc stored as parquet as create table indi_pub_hybrid_oa_with_cc stored as parquet as
WITH hybrid_oa AS (SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_print as issn WITH hybrid_oa AS (
FROM stats_ext.plan_s_jn SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_print as issn
WHERE issn_print != "" FROM stats_ext.plan_s_jn
UNION ALL WHERE issn_print != ""
SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_online as issn UNION ALL
FROM stats_ext.plan_s_jn SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_online as issn
WHERE issn_online != "" and (journal_is_in_doaj = FALSE OR journal_is_oa = FALSE)), FROM stats_ext.plan_s_jn
issn AS (SELECT * FROM WHERE issn_online != "" and (journal_is_in_doaj = FALSE OR journal_is_oa = FALSE)),
(SELECT id, issn_printed as issn issn AS (
FROM datasource SELECT *
WHERE issn_printed IS NOT NULL FROM (
UNION SELECT id, issn_printed as issn
SELECT id,issn_online as issn FROM datasource
FROM datasource WHERE issn_printed IS NOT NULL
WHERE issn_online IS NOT NULL ) as issn UNION
WHERE LENGTH(issn) > 7) SELECT id,issn_online as issn
FROM datasource
WHERE issn_online IS NOT NULL ) as issn
WHERE LENGTH(issn) > 7)
SELECT DISTINCT pd.id, coalesce(is_hybrid_oa, 0) as is_hybrid_oa SELECT DISTINCT pd.id, coalesce(is_hybrid_oa, 0) as is_hybrid_oa
FROM publication_datasources pd FROM publication_datasources pd
LEFT OUTER JOIN ( LEFT OUTER JOIN (
SELECT pd.id, 1 as is_hybrid_oa from publication_datasources pd SELECT pd.id, 1 as is_hybrid_oa from publication_datasources pd
JOIN datasource d on d.id=pd.datasource JOIN datasource d on d.id=pd.datasource
JOIN issn on issn.id=pd.datasource JOIN issn on issn.id=pd.datasource
JOIN hybrid_oa ON issn.issn = hybrid_oa.issn JOIN hybrid_oa ON issn.issn = hybrid_oa.issn
JOIN indi_result_has_cc_licence cc on pd.id=cc.id JOIN indi_result_has_cc_licence cc on pd.id=cc.id
where cc.has_cc_license=1) tmp where cc.has_cc_license=1) tmp on pd.id=tmp.id;
on pd.id=tmp.id;
create table indi_pub_downloads stored as parquet as
SELECT result_id, sum(downloads) no_dowloads from openaire_prod_usage_stats.usage_stats
join publication on result_id=id
where downloads>0
GROUP BY result_id
order by no_dowloads desc;
create table indi_pub_downloads_datasource stored as parquet as
SELECT result_id, repository_id, sum(downloads) no_dowloads from openaire_prod_usage_stats.usage_stats
join publication on result_id=id
where downloads>0
GROUP BY result_id, repository_id
order by result_id;
create table indi_pub_downloads_year stored as parquet as
SELECT result_id, substring(us.`date`, 1,4) as `year`, sum(downloads) no_dowloads from openaire_prod_usage_stats.usage_stats us
join publication on result_id=id where downloads>0
GROUP BY result_id, `year`
order by `year` asc;
create table indi_pub_downloads_datasource_year stored as parquet as
SELECT result_id, substring(us.`date`, 1,4) as `year`, repository_id, sum(downloads) no_dowloads from openaire_prod_usage_stats.usage_stats us
join publication on result_id=id
where downloads>0
GROUP BY result_id, repository_id, `year`
order by `year` asc, result_id;

View File

@ -123,6 +123,10 @@ create table TARGET.indi_pub_doi_from_crossref stored as parquet as select * fro
compute stats TARGET.indi_pub_doi_from_crossref; compute stats TARGET.indi_pub_doi_from_crossref;
create table TARGET.indi_pub_gold_oa stored as parquet as select * from SOURCE.indi_pub_gold_oa orig where exists (select 1 from TARGET.result r where r.id=orig.id); create table TARGET.indi_pub_gold_oa stored as parquet as select * from SOURCE.indi_pub_gold_oa orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_pub_gold_oa; compute stats TARGET.indi_pub_gold_oa;
create table TARGET.indi_datasets_gold_oa stored as parquet as select * from SOURCE.indi_datasets_gold_oa orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_datasets_gold_oa;
create table TARGET.indi_software_gold_oa stored as parquet as select * from SOURCE.indi_software_gold_oa orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_software_gold_oa;
create table TARGET.indi_pub_has_abstract stored as parquet as select * from SOURCE.indi_pub_has_abstract orig where exists (select 1 from TARGET.result r where r.id=orig.id); create table TARGET.indi_pub_has_abstract stored as parquet as select * from SOURCE.indi_pub_has_abstract orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_pub_has_abstract; compute stats TARGET.indi_pub_has_abstract;
create table TARGET.indi_result_has_cc_licence stored as parquet as select * from SOURCE.indi_result_has_cc_licence orig where exists (select 1 from TARGET.result r where r.id=orig.id); create table TARGET.indi_result_has_cc_licence stored as parquet as select * from SOURCE.indi_result_has_cc_licence orig where exists (select 1 from TARGET.result r where r.id=orig.id);
@ -148,6 +152,11 @@ compute stats TARGET.indi_pub_closed_other_open;
create table TARGET.indi_result_no_of_copies stored as parquet as select * from SOURCE.indi_result_no_of_copies orig where exists (select 1 from TARGET.result r where r.id=orig.id); create table TARGET.indi_result_no_of_copies stored as parquet as select * from SOURCE.indi_result_no_of_copies orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_result_no_of_copies; compute stats TARGET.indi_result_no_of_copies;
create view TARGET.indi_org_findable as select * from SOURCE.indi_org_findable;
create view TARGET.indi_org_openess as select * from SOURCE.indi_org_openess;
create table TARGET.indi_pub_hybrid_oa_with_cc stored as parquet as select * from SOURCE.indi_pub_hybrid_oa_with_cc orig where exists (select 1 from TARGET.result r where r.id=orig.id);
compute stats TARGET.indi_pub_hybrid_oa_with_cc;
--- Usage statistics --- Usage statistics
create table TARGET.usage_stats stored as parquet as select * from SOURCE.usage_stats orig where exists (select 1 from TARGET.result r where r.id=orig.result_id); create table TARGET.usage_stats stored as parquet as select * from SOURCE.usage_stats orig where exists (select 1 from TARGET.result r where r.id=orig.result_id);