Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions v2.0/helpers/datasets/datasetqueryfaster.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ WITH filtered_datasets AS (
ORDER BY bigq.siteid, bigq.datasetid
-- This is cheating a bit. We're querying a smaller chunk here and hoping that taking 3 times the datasets is enough
-- to get us the actual limit.
LIMIT COALESCE(${limit}, 25) * 3
OFFSET COALESCE(${offset}, 0)
-- LIMIT COALESCE(${limit}, 25) * 3
-- OFFSET COALESCE(${offset}, 0)
Comment on lines 25 to +29
),
-- Now these CTEs work on a much smaller dataset
dataset_dois AS (
Expand Down
16 changes: 8 additions & 8 deletions v2.0/helpers/publications/pubdsidquery.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WITH dpub AS
(SELECT * FROM
ndb.datasetpublications as dp
WHERE ($1 IS NULL OR dp.datasetid IN ($1:csv)))
WITH dpub AS (
SELECT * FROM ndb.datasetpublications AS dp
WHERE ($1 IS NULL OR dp.datasetid IN ($1:csv))
)
SELECT json_build_object(
'datasets', json_agg(DISTINCT jsonb_build_object('siteid', dsl.siteid,
'datasetid', dpub.datasetid,
Expand Down Expand Up @@ -35,9 +35,9 @@ SELECT json_build_object(
'givennames', ca.givennames,
'order', pa.authororder))) AS publication
FROM ndb.publications AS pub
INNER JOIN ndb.publicationauthors AS pa ON pub.publicationid = pa.publicationid
INNER JOIN ndb.contacts as ca ON ca.contactid = pa.contactid
INNER JOIN ndb.publicationtypes AS pt ON pub.pubtypeid = pt.pubtypeid
INNER JOIN (SELECT * FROM dpub) AS dpub ON dpub.publicationid = pub.publicationid
INNER JOIN dpub ON dpub.publicationid = pub.publicationid
LEFT JOIN ndb.publicationauthors AS pa ON pub.publicationid = pa.publicationid
LEFT JOIN ndb.contacts as ca ON ca.contactid = pa.contactid
LEFT JOIN ndb.publicationtypes AS pt ON pub.pubtypeid = pt.pubtypeid
LEFT JOIN ndb.dslinks AS dsl ON dsl.datasetid = dpub.datasetid
GROUP BY pub.publicationid, pt.pubtype
25 changes: 1 addition & 24 deletions v2.0/helpers/publications/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,10 @@ function publicationbydataset (req, res, next) {

db.any(pubbydsid, [datasetid])
.then(function (data) {
// var bibOutput = bib.formatpublbib(data);
var bibOutput = data;

/* This is a sequence I use to aggregate the publications by site */
var returner = [];
var uniquepubs = bibOutput.map(x => x.publicationid).filter((x, i, a) => a.indexOf(x) === i)

for (var i = 0; i < uniquepubs.length; i++) {
returner[i] = { 'publicationid': uniquepubs[i] }
}

for (i = 0; i < bibOutput.length; i++) {
var returnid = returner.map(x => x.publicationid).indexOf(bibOutput[i].publicationid)

if (!('title' in returner[returnid])) {
/* Using `title` as a placeholder for any record that hasn't been added. */
returner[returnid] = bibOutput[i]
returner[returnid].datasetid = [returner[returnid].datasetid]
} else {
returner[returnid]['datasetid'].push(bibOutput[i].datasetid);
}
}

res.status(200)
.json({
status: 'success',
data: bibOutput,
data: data,
message: 'Retrieved all tables'
});
})
Expand Down