diff --git a/Model/bin/showNewCommentLinks b/Model/bin/showNewCommentLinks index e85d38f4c..ee2a2bf06 100755 --- a/Model/bin/showNewCommentLinks +++ b/Model/bin/showNewCommentLinks @@ -8,7 +8,7 @@ use Data::Dumper; use Getopt::Long qw(GetOptions); use ApiCommonData::Load::TuningConfig::Utils; -my ($propfile, $instance, $schema, $password, $suffix, $prefix, $dblink, $subversionDir, $debug); +my ($propfile, $instance, $schema, $password, $suffix, $prefix, $remoteUserSchema, $subversionDir, $debug); Getopt::Long::Configure("pass_through"); GetOptions("propfile=s" => \$propfile, "instance=s" => \$instance, @@ -16,7 +16,7 @@ GetOptions("propfile=s" => \$propfile, "password=s" => \$password, "suffix=s" => \$suffix, "prefix=s" => \$prefix, - "dblink=s" => \$dblink, + "remoteUserSchema=s" => \$remoteUserSchema, "subversionDir=s" => \$subversionDir, "debug!" => \$debug, ); @@ -27,7 +27,7 @@ my $dbh = ApiCommonData::Load::TuningConfig::Utils::getDbHandle($instance, $sche my $csiTable = $prefix . "NewCsi"; my $stmt = $dbh->prepare(< - - + diff --git a/Model/lib/wdk/model/questions/params/metricsParams.xml b/Model/lib/wdk/model/questions/params/metricsParams.xml index ef9e0b9f1..5c11942ca 100644 --- a/Model/lib/wdk/model/questions/params/metricsParams.xml +++ b/Model/lib/wdk/model/questions/params/metricsParams.xml @@ -76,7 +76,7 @@ CASE when project_id in ('EuPathDB') then 'VEuPathDB' else project_id end as display - FROM metrics.SEARCHESSTATS@USER_DBLINK@) + FROM @REMOTE_METRICS_SCHEMA@.SEARCHESSTATS) ORDER BY display ]]> @@ -92,7 +92,7 @@ CASE when project_id in ('EuPathDB') then 'VEuPathDB' else project_id end as display - FROM metrics.ORGANISMVIEWSTATS@USER_DBLINK@) + FROM @REMOTE_METRICS_SCHEMA@.ORGANISMVIEWSTATS) ORDER BY display ]]> @@ -108,7 +108,7 @@ CASE when project_id in ('EuPathDB') then 'VEuPathDB' else project_id end as display - FROM metrics.GENEPAGETABLESTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.GENEPAGETABLESTATS WHERE project_id is not null) ORDER BY display ]]> diff --git a/Model/lib/wdk/model/questions/params/sharedParams.xml b/Model/lib/wdk/model/questions/params/sharedParams.xml index 0f48be89e..4a61feeb0 100644 --- a/Model/lib/wdk/model/questions/params/sharedParams.xml +++ b/Model/lib/wdk/model/questions/params/sharedParams.xml @@ -1518,8 +1518,6 @@ This parameter allows you to apply the minimum number of peptides to each select - @@ -2817,22 +2815,6 @@ This parameter allows you to apply the minimum number of peptides to each select - - - - - - - SELECT term, display, rownum AS internal - FROM ( - SELECT a.question_name AS term, count(s.step_id) AS display - FROM @WDK_ENGINE_SCHEMA@answers@USER_DBLINK@ a, @USER_SCHEMA@steps@USER_DBLINK@ s - WHERE a.answer_id = s.step_id - GROUP BY a.question_name - ) t - - - diff --git a/Model/lib/wdk/model/questions/queries/geneQueries.xml b/Model/lib/wdk/model/questions/queries/geneQueries.xml index 80d8eec54..5add2b91f 100644 --- a/Model/lib/wdk/model/questions/queries/geneQueries.xml +++ b/Model/lib/wdk/model/questions/queries/geneQueries.xml @@ -6444,7 +6444,7 @@ select distinct ta.gene_source_id SELECT stable_id, substr(headline, 1, 80) as headline, count(*) as comment_count, min(comment_date) as min_comment_date, max(comment_date) as max_comment_date - FROM @COMMENT_SCHEMA@MappedComment@COMMENT_DBLINK@ + FROM @REMOTE_COMMENT_SCHEMA@MappedComment WHERE ('@PROJECT_ID@' = 'UniDB' OR project_name = '@PROJECT_ID@') and is_visible = 1 GROUP BY stable_id, headline diff --git a/Model/lib/wdk/model/questions/queries/metricsQueries.xml b/Model/lib/wdk/model/questions/queries/metricsQueries.xml index 75d36d636..310ad8261 100644 --- a/Model/lib/wdk/model/questions/queries/metricsQueries.xml +++ b/Model/lib/wdk/model/questions/queries/metricsQueries.xml @@ -32,7 +32,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project,unique_visitors,visits,page_data_requests,avg_visit_duration,bandwidth_gb,start_date,end_date - FROM METRICS.AWSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.AWSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ +1 @@ -71,7 +71,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project, unique_logins, newly_registered, newly_registered_notLogin, total_registered, start_date, end_date - FROM METRICS.LOGINSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.LOGINSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -117,7 +117,7 @@ SELECT project_id as project, registered_users_count, registered_page_count, guest_users_count, guest_page_count, registered_IP_count, guest_IP_count, guest_users_regPage_pct, guest_IP_regPage_pct, guest_users_regPage_newly_registered_pct, start_date, end_date - FROM METRICS.PAGEVIEWSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.PAGEVIEWSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -152,7 +152,7 @@ url_segment, count, to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project, url_segment, count, start_date, end_date - FROM METRICS.RECORDPAGEVIEWSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.RECORDPAGEVIEWSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -192,7 +192,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project, dataset_type, total_complete, total_incomplete, new_complete, new_incomplete, start_date, end_date - FROM METRICS.USERDATASETSSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.USERDATASETSSTATS WHERE project_id in ( $$projectIdNoPortalSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -233,7 +233,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT ovs.project_id as project, organism, IS_REFERENCE_STRAIN as is_reference, oa.project_id as org_project, count, start_date, end_date - FROM METRICS.ORGANISMVIEWSTATS@USER_DBLINK@ ovs + FROM @REMOTE_METRICS_SCHEMA@.ORGANISMVIEWSTATS ovs LEFT OUTER JOIN apidbtuning.organismattributes oa ON ovs.organism = oa.ORGANISM_NAME WHERE ovs.project_id in ( $$projectIdNoAllSelect$$ ) @@ -241,7 +241,7 @@ AND end_date <= $$date.max$$ + 1 UNION SELECT ovs.project_id as project, organism, IS_REFERENCE_STRAIN as is_reference, oa.project_id as org_project, count, start_date, end_date - FROM METRICS.ORGANISMVIEWSTATS@USER_DBLINK@ ovs + FROM @REMOTE_METRICS_SCHEMA@.ORGANISMVIEWSTATS ovs LEFT OUTER JOIN apidbtuning.organismattributes oa ON ovs.organism = oa.ORGANISM_NAME WHERE ovs.project_id = 'Unknown' @@ -283,7 +283,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project, number_of_organisms, steps_count, start_date, end_date - FROM METRICS.ORGANISMSPERSTEP@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.ORGANISMSPERSTEP WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -320,7 +320,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT ovs.project_id as project, ovs.organism, IS_REFERENCE_STRAIN as is_reference, steps_count, oa.project_id as org_project, start_date, end_date - FROM METRICS.STEPSPERORGANISM@USER_DBLINK@ ovs + FROM @REMOTE_METRICS_SCHEMA@.STEPSPERORGANISM ovs LEFT OUTER JOIN apidbtuning.organismattributes oa ON ovs.organism = oa.ORGANISM_NAME WHERE ovs.project_id in ( $$projectIdNoAllSelect$$ ) @@ -360,7 +360,7 @@ to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id,RECORD_CLASS_URL_SEGMENT as record_class,table_name,count,start_date,end_date - FROM METRICS.GENEPAGETABLESTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.GENEPAGETABLESTATS WHERE start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 AND project_id in ( $$projectIdNoPortalSelect$$ ) @@ -397,7 +397,7 @@ tool,count,to_char(start_date,'YYYY-MM-DD') as start_date, to_char(end_date,'YYYY-MM-DD') as end_date FROM ( SELECT project_id as project,tool,count,start_date,end_date - FROM METRICS.TOOLSSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.TOOLSSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND start_date >= $$date.min$$ AND end_date <= $$date.max$$ + 1 @@ -440,7 +440,7 @@ SELECT project_id as project, steps_count, start_date, end_date, SUBSTR(search_name, 1, INSTR(search_name, '.')-1) AS record_name, SUBSTR(search_name, INSTR(search_name, '.')+1) AS singlesearch_name - FROM METRICS.SEARCHESSTATS@USER_DBLINK@ + FROM @REMOTE_METRICS_SCHEMA@.SEARCHESSTATS WHERE project_id in ( $$projectIdSelect$$ ) AND steps_count >= $$step_count.min$$ AND steps_count <= $$step_count.max$$ diff --git a/Model/lib/wdk/model/questions/queries/universalQueries.xml b/Model/lib/wdk/model/questions/queries/universalQueries.xml index b449c65f0..2dc877cec 100644 --- a/Model/lib/wdk/model/questions/queries/universalQueries.xml +++ b/Model/lib/wdk/model/questions/queries/universalQueries.xml @@ -77,7 +77,7 @@ diff --git a/Model/lib/wdk/model/records/commentTableQueries.xml b/Model/lib/wdk/model/records/commentTableQueries.xml index e95d39a19..b8b13ed30 100644 --- a/Model/lib/wdk/model/records/commentTableQueries.xml +++ b/Model/lib/wdk/model/records/commentTableQueries.xml @@ -95,24 +95,24 @@ &&selectReviewed&& u.first_name || ' ' || u.last_name || ', ' || u.organization as user_name_org FROM - @COMMENT_SCHEMA@MappedComment c + @REMOTE_COMMENT_SCHEMA@MappedComment c INNER JOIN apidbtuning.GeneAttributes ga ON c.project_name = ga.project_id AND c.stable_id = ga.source_id - INNER JOIN @COMMENT_SCHEMA@comment_users u ON c.user_id = u.user_id + INNER JOIN @REMOTE_COMMENT_SCHEMA@comment_users u ON c.user_id = u.user_id INNER JOIN apidbtuning.annotatedgenomesummary ags ON ga.taxon_id = ags.taxon_id LEFT JOIN ( SELECT comment_id, count(*) as filecount - FROM @COMMENT_SCHEMA@CommentFile + FROM @REMOTE_COMMENT_SCHEMA@CommentFile GROUP BY comment_id ) files ON c.comment_id = files.comment_id LEFT JOIN ( SELECT comment_id, string_agg(source_id,',') as pmids - FROM @COMMENT_SCHEMA@CommentReference + FROM @REMOTE_COMMENT_SCHEMA@CommentReference WHERE database_name='pubmed' GROUP BY comment_id ) refs ON c.comment_id = refs.comment_id LEFT JOIN ( SELECT comment_id, COUNT(DISTINCT stable_id) AS geneCount - FROM @COMMENT_SCHEMA@MappedComment + FROM @REMOTE_COMMENT_SCHEMA@MappedComment WHERE stable_id IN (SELECT source_id FROM apidbTuning.GeneAttributes) GROUP BY comment_id ) gene_counts ON c.comment_id = gene_counts.comment_id @@ -194,28 +194,28 @@ u.first_name || ' ' || u.last_name || ', ' || u.organization as user_name_org, authortable.authors FROM - @COMMENT_SCHEMA@MappedComment c - INNER JOIN @COMMENT_SCHEMA@comment_users u c.user_id = u.user_id + @REMOTE_COMMENT_SCHEMA@MappedComment c + INNER JOIN @REMOTE_COMMENT_SCHEMA@comment_users u c.user_id = u.user_id LEFT JOIN ( SELECT comment_id, count(*) as filecount - FROM @COMMENT_SCHEMA@CommentFile + FROM @REMOTE_COMMENT_SCHEMA@CommentFile GROUP BY comment_id ) files ON c.comment_id = files.comment_id LEFT JOIN ( SELECT comment_id, string_agg(source_id,',') as pmids - FROM @COMMENT_SCHEMA@CommentReference + FROM @REMOTE_COMMENT_SCHEMA@CommentReference WHERE database_name='pubmed' GROUP BY comment_id ) refs ON c.comment_id = refs.comment_id LEFT JOIN ( SELECT comment_id, string_agg(source_id,',') as authors - FROM @COMMENT_SCHEMA@CommentReference + FROM @REMOTE_COMMENT_SCHEMA@CommentReference WHERE database_name='author' GROUP BY comment_id ) authortable ON c.comment_id = authortable.comment_id LEFT JOIN ( SELECT comment_id, count(stable_id) as geneCount - FROM @COMMENT_SCHEMA@MappedComment + FROM @REMOTE_COMMENT_SCHEMA@MappedComment GROUP BY comment_id ) gene_counts c.comment_id = gene_counts.comment_id WHERE ('@PROJECT_ID@' = 'UniDB' OR c.project_name = '@PROJECT_ID@') @@ -252,22 +252,22 @@ SELECT c.comment_target_id, c.project_name as project_id, c.comment_id, c.stable_id, c.comment_date, c.headline, files.filecount, refs.pmids, gene_counts.geneCount, u.first_name || ' ' || u.last_name || ', ' || u.organization as user_name_org - FROM @COMMENT_SCHEMA@MappedComment c - INNER JOIN @COMMENT_SCHEMA@comment_users u ON c.user_id = u.user_id + FROM @REMOTE_COMMENT_SCHEMA@MappedComment c + INNER JOIN @REMOTE_COMMENT_SCHEMA@comment_users u ON c.user_id = u.user_id LEFT JOIN ( SELECT comment_id, count(*) as filecount - FROM @COMMENT_SCHEMA@CommentFile + FROM @REMOTE_COMMENT_SCHEMA@CommentFile GROUP BY comment_id ) files ON c.comment_id = files.comment_id LEFT JOIN ( SELECT comment_id, string_agg(source_id,',') as pmids - FROM @COMMENT_SCHEMA@CommentReference + FROM @REMOTE_COMMENT_SCHEMA@CommentReference WHERE database_name='pubmed' GROUP BY comment_id ) refs ON c.comment_id = refs.comment_id LEFT JOIN ( SELECT comment_id, count(stable_id) as geneCount - FROM @COMMENT_SCHEMA@mappedComment + FROM @REMOTE_COMMENT_SCHEMA@mappedComment GROUP BY comment_id ) gene_counts ON c.comment_id = gene_counts.comment_id WHERE ('@PROJECT_ID@' = 'UniDB' OR c.project_name = '@PROJECT_ID@') @@ -297,9 +297,9 @@ = 1 - -- THEN 'View ' - -- || comm.num_user_comments || ' user comment' - -- || CASE WHEN comm.num_user_comments = 1 - -- THEN '' - -- ELSE 's' - -- END - -- ELSE 'Add the first User Comment' - -- END AS user_comment_link_text, - -- coalesce(comm.num_user_comments, 0) AS num_user_comments, - 'TODO' as user_comment_link_text, - 0 as num_user_comments, + CASE WHEN comm.num_user_comments >= 1 + THEN 'View ' + || comm.num_user_comments || ' user comment' + || CASE WHEN comm.num_user_comments = 1 + THEN '' + ELSE 's' + END + ELSE 'Add the first User Comment' + END AS user_comment_link_text, + coalesce(comm.num_user_comments, 0) AS num_user_comments, CASE WHEN (ga.project_id NOT IN ('HostDB') AND aid.apolloid IS NOT NULL AND ga.organism NOT IN ('Candida dubliniensis CD36') @@ -401,21 +399,12 @@ GROUP BY source_id apidbtuning.geneattributes ga INNER JOIN apidbtuning.annotatedgenomesummary gsum ON gsum.taxon_id = ga.taxon_id LEFT JOIN apidbtuning.ApolloID aid ON ga.organism = aid.organism - -- LEFT JOIN ( - -- SELECT stable_id AS gene_id, project_name, count(distinct comment_id) AS num_user_comments - -- FROM ( - -- SELECT * - -- FROM dblink('dbname=apicommS options=-csearch_path=', - -- 'select * from userlogins5.mappedcomment') - -- AS t1(COMMENT_ID NUMERIC(10), USER_ID NUMERIC(12), EMAIL VARCHAR(255), COMMENT_DATE TIMESTAMP, COMMENT_TARGET_ID VARCHAR(20), STABLE_ID VARCHAR(200) - -- , CONCEPTUAL NUMERIC(1), PROJECT_NAME VARCHAR(200), PROJECT_VERSION VARCHAR(100), HEADLINE VARCHAR(2000), REVIEW_STATUS_ID VARCHAR(20) - -- , ACCEPTED_VERSION VARCHAR(100), LOCATION_STRING VARCHAR(1000), ORGANISM VARCHAR(100), IS_VISIBLE NUMERIC(1) - -- ) - -- ) t - -- FROM @COMMENT_SCHEMA@MappedComment@COMMENT_DBLINK@ - -- WHERE is_visible = 1 - -- GROUP BY stable_id, project_name - -- ) comm ON ga.source_id = comm.gene_id AND ga.project_id = comm.project_name + LEFT JOIN ( + SELECT stable_id AS gene_id, project_name, count(distinct comment_id) AS num_user_comments + FROM @REMOTE_COMMENT_SCHEMA@MappedComment + WHERE is_visible = 1 + GROUP BY stable_id, project_name + ) comm ON ga.source_id = comm.gene_id AND ga.project_id = comm.project_name ]]> diff --git a/Model/lib/wdk/model/records/geneTableQueries.xml b/Model/lib/wdk/model/records/geneTableQueries.xml index bcdf99863..e8d3477dd 100644 --- a/Model/lib/wdk/model/records/geneTableQueries.xml +++ b/Model/lib/wdk/model/records/geneTableQueries.xml @@ -2526,7 +2526,7 @@ from ( WITH comments AS ( SELECT DISTINCT stable_id - FROM @COMMENT_SCHEMA@MappedComment@COMMENT_DBLINK@ + FROM @REMOTE_COMMENT_SCHEMA@MappedComment WHERE comment_target_id = 'gene' AND review_status_id != 'rejected' AND is_visible = 1 diff --git a/Model/lib/wdk/model/records/userfileRecords.xml b/Model/lib/wdk/model/records/userfileRecords.xml index 62f67cab0..4369532e8 100644 --- a/Model/lib/wdk/model/records/userfileRecords.xml +++ b/Model/lib/wdk/model/records/userfileRecords.xml @@ -60,13 +60,13 @@ ' || rtrim(max(case when key = 'organization' then value end)) as provider - FROM useraccounts.account_properties@ACCT_DBLINK@ + FROM @REMOTE_USERACCOUNTS_SCHEMA@.account_properties GROUP BY user_id ) ap ON a.user_id = ap.user_id ) @@ -74,7 +74,7 @@ f.filename, f.title, f.notes, to_char(f.uploadtime,'YYYY-MM-DD HH24:MI:SS') AS uploadtime, f.filesize, f.format, u.provider - FROM uploads.UserFile@USER_DBLINK@ f, users u + FROM @REMOTE_UPLOADS_SCHEMA@.UserFile f, users u WHERE f.owneruserid = u.signature (+) AND projectname = '@PROJECT_ID@' ]]>