Skip to content

Commit

Permalink
Metrics QA fixes #4527
Browse files Browse the repository at this point in the history
Removed concat usage
Added correct datasetsBySubject query
Updated docs on default metrics timeout
  • Loading branch information
matthew-a-dunlap committed May 22, 2018
1 parent 4e1471b commit a8fcd3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,6 @@ Enable the collection of provenance metadata on Dataverse via the provenance pop
:MetricsCacheTimeoutMinutes
+++++++++++++++++++++++++++

Sets how long a cached metrics result is used before re-running the query for a request. Note this only effects queries on the current month, previous months queries are cached indefinitely.
Sets how long a cached metrics result is used before re-running the query for a request. Note this only effects queries on the current month, previous months queries are cached indefinitely. The default timeout is 7 days (10080 minutes).

``curl -X PUT -d 10080 http://localhost:8080/api/admin/settings/:MetricsCacheTimeoutMinutes``
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public long datasetsByMonth(String yyyymm) throws Exception {
Query query = em.createNativeQuery(""
+ "select count(*)\n"
+ "from datasetversion\n"
+ "where concat(datasetversion.dataset_id,':', datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber)) in \n"
+ "where datasetversion.dataset_id || ':' || datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber) in \n"
+ "(\n"
+ "select concat(datasetversion.dataset_id,':', max(datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber))) as max \n"
+ "select datasetversion.dataset_id || ':' || max(datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber)) as max \n"
+ "from datasetversion\n"
+ "join dataset on dataset.id = datasetversion.dataset_id\n"
+ "where versionstate='RELEASED' \n"
Expand All @@ -75,9 +75,9 @@ public long filesByMonth(String yyyymm) throws Exception {
+ "select count(*)\n"
+ "from filemetadata\n"
+ "join datasetversion on datasetversion.id = filemetadata.datasetversion_id\n"
+ "where concat(datasetversion.dataset_id,':', datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber)) in \n"
+ "where datasetversion.dataset_id || ':' || datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber) in \n"
+ "(\n"
+ "select concat(datasetversion.dataset_id,':', max(datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber))) as max \n"
+ "select datasetversion.dataset_id || ':' || max(datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber)) as max \n"
+ "from datasetversion\n"
+ "join dataset on dataset.id = datasetversion.dataset_id\n"
+ "where versionstate='RELEASED'\n"
Expand Down Expand Up @@ -120,20 +120,28 @@ public List<Object[]> dataversesByCategory() throws Exception {

public List<Object[]> datasetsBySubject() {
Query query = em.createNativeQuery(""
+ "SELECT strvalue, count(dataset.id)\n"
+ "FROM datasetfield_controlledvocabularyvalue \n"
+ "JOIN controlledvocabularyvalue ON controlledvocabularyvalue.id = datasetfield_controlledvocabularyvalue.controlledvocabularyvalues_id\n"
+ "JOIN datasetfield ON datasetfield.id = datasetfield_controlledvocabularyvalue.datasetfield_id\n"
+ "JOIN datasetfieldtype ON datasetfieldtype.id = controlledvocabularyvalue.datasetfieldtype_id\n"
+ "JOIN datasetversion ON datasetversion.id = datasetfield.datasetversion_id\n"
+ "JOIN dvobject ON dvobject.id = datasetversion.dataset_id\n"
+ "JOIN dataset ON dataset.id = datasetversion.dataset_id\n"
+ "WHERE\n"
+ "datasetfieldtype.name = 'subject'\n"
+ "AND dvobject.publicationdate is NOT NULL\n"
+ "AND dataset.harvestingclient_id IS NULL\n"
+ "GROUP BY strvalue\n"
+ "ORDER BY count(dataset.id) desc;"
+ "SELECT strvalue, count(dataset.id)\n"
+ "FROM datasetfield_controlledvocabularyvalue \n"
+ "JOIN controlledvocabularyvalue ON controlledvocabularyvalue.id = datasetfield_controlledvocabularyvalue.controlledvocabularyvalues_id\n"
+ "JOIN datasetfield ON datasetfield.id = datasetfield_controlledvocabularyvalue.datasetfield_id\n"
+ "JOIN datasetfieldtype ON datasetfieldtype.id = controlledvocabularyvalue.datasetfieldtype_id\n"
+ "JOIN datasetversion ON datasetversion.id = datasetfield.datasetversion_id\n"
+ "JOIN dvobject ON dvobject.id = datasetversion.dataset_id\n"
+ "JOIN dataset ON dataset.id = datasetversion.dataset_id\n"
+ "WHERE\n"
+ "datasetversion.dataset_id || ':' || datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber) in \n"
+ "(\n"
+ "select datasetversion.dataset_id || ':' || max(datasetversion.versionnumber + (.1 * datasetversion.minorversionnumber)) as max \n"
+ "from datasetversion\n"
+ "join dataset on dataset.id = datasetversion.dataset_id\n"
+ "where versionstate='RELEASED'\n"
+ "and date_trunc('month', releasetime) <= to_date('2018-05','YYYY-MM')\n"

This comment has been minimized.

Copy link
@pdurbin

pdurbin May 22, 2018

Member

"2018-05" shouldn't be here

+ "and dataset.harvestingclient_id is null\n"
+ "group by dataset_id \n"
+ ")\n"
+ "AND datasetfieldtype.name = 'subject'\n"
+ "GROUP BY strvalue\n"
+ "ORDER BY count(dataset.id) desc;"
);
logger.info("query: " + query);

Expand Down

0 comments on commit a8fcd3e

Please sign in to comment.