--PeDOCS old data

DROP TABLE IF EXISTS ${usageStatsDB}.pedocs_views_stats_tmp;

DROP TABLE IF EXISTS ${usageStatsDB}.pedocs_downloads_stats_tmp;

CREATE TABLE IF NOT EXISTS ${usageStatsDB}.pedocs_views_stats_tmp AS
SELECT 'OpenAIRE' as source, 'opendoar____::ab1a4d0dd4d48a2ba1077c4494791306' as repository_id,
r.id as result_id,date,counter_abstract as count, 0 as openaire
FROM ${usageRawDataDB}.pedocsoldviews p, ${statsDB}.result_oids r where r.oid=p.identifier;

CREATE TABLE IF NOT EXISTS ${usageStatsDB}.pedocs_downloads_stats_tmp AS
SELECT 'OpenAIRE' as source, 'opendoar____::ab1a4d0dd4d48a2ba1077c4494791306' as repository_id,
r.id as result_id, date, counter as count, 0 as openaire
FROM ${usageRawDataDB}.pedocsolddownloads p, ${statsDB}.result_oids r where r.oid=p.identifier;
