updated table definitions for views so that they deliver the correct information

history-download
youainti 4 years ago
parent 2aa8fdee4e
commit 5bd3d4ee95

@ -92,14 +92,23 @@ Views to allow downloader programs to identify what to download.
CREATE OR REPLACE VIEW http.most_recent_download_status
AS
SELECT download_status.nct_id,
SELECT t.nct_id,
t.status,
t.update_timestamp
FROM ( SELECT download_status.id,
download_status.nct_id,
download_status.status,
max(download_status.update_timestamp) AS max
FROM http.download_status
GROUP BY download_status.nct_id, download_status.status;
download_status.update_timestamp,
row_number() OVER (PARTITION BY download_status.nct_id ORDER BY download_status.update_timestamp DESC) AS rn
FROM http.download_status) t
WHERE t.rn = 1
ORDER BY t.nct_id;
ALTER TABLE http.most_recent_download_status
OWNER TO http_requestor;
OWNER TO root;
COMMENT ON VIEW http.most_recent_download_status
IS 'List of most recent download status';
-- View: http.trials_to_download
@ -108,14 +117,12 @@ ALTER TABLE http.most_recent_download_status
CREATE OR REPLACE VIEW http.trials_to_download
AS
SELECT most_recent_download_status.nct_id,
most_recent_download_status.status,
most_recent_download_status.max
SELECT most_recent_download_status.nct_id
FROM http.most_recent_download_status
WHERE most_recent_download_status.status = 'Of Interest'::http.history_download_status;
ALTER TABLE http.trials_to_download
OWNER TO http_requestor;
OWNER TO root;
COMMENT ON VIEW http.trials_to_download
IS 'List of trials for which the history needs downloaded';

Loading…
Cancel
Save