Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
retrieve files with status only ready
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdots committed Jan 23, 2024
1 parent b9ae7d1 commit 7e9802b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (suite *S3TestSuite) TestListByPrefix() {
FROM sda.files
JOIN sda.file_dataset ON file_id = files.id
JOIN sda.datasets ON file_dataset.dataset_id = datasets.id
LEFT JOIN \(SELECT file_id, \(ARRAY_AGG\(event ORDER BY started_at DESC\)\)\[1\] AS event FROM sda.file_event_log GROUP BY file_id\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready'\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, checksum, type FROM sda.checksums WHERE source = 'UNENCRYPTED'\) sha ON files.id = sha.file_id
WHERE datasets.stable_id = \$1;
`
Expand Down Expand Up @@ -228,7 +228,7 @@ func (suite *S3TestSuite) TestListObjects() {
FROM sda.files
JOIN sda.file_dataset ON file_id = files.id
JOIN sda.datasets ON file_dataset.dataset_id = datasets.id
LEFT JOIN \(SELECT file_id, \(ARRAY_AGG\(event ORDER BY started_at DESC\)\)\[1\] AS event FROM sda.file_event_log GROUP BY file_id\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready'\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, checksum, type FROM sda.checksums WHERE source = 'UNENCRYPTED'\) sha ON files.id = sha.file_id
WHERE datasets.stable_id = \$1;
`
Expand Down
7 changes: 2 additions & 5 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (dbs *SQLdb) getFiles(datasetID string) ([]*FileInfo, error) {
FROM sda.files
JOIN sda.file_dataset ON file_id = files.id
JOIN sda.datasets ON file_dataset.dataset_id = datasets.id
LEFT JOIN (SELECT file_id, (ARRAY_AGG(event ORDER BY started_at DESC))[1] AS event FROM sda.file_event_log GROUP BY file_id) log ON files.id = log.file_id
LEFT JOIN (SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready') log ON files.id = log.file_id
LEFT JOIN (SELECT file_id, checksum, type FROM sda.checksums WHERE source = 'UNENCRYPTED') sha ON files.id = sha.file_id
WHERE datasets.stable_id = $1;
`
Expand Down Expand Up @@ -341,10 +341,7 @@ func (dbs *SQLdb) getDatasetFileInfo(datasetID, filePath string) (*FileInfo, err
FROM sda.files f
JOIN sda.file_dataset fd ON fd.file_id = f.id
JOIN sda.datasets d ON fd.dataset_id = d.id
LEFT JOIN (SELECT file_id,
(ARRAY_AGG(event ORDER BY started_at DESC))[1] AS event
FROM sda.file_event_log
GROUP BY file_id) e
LEFT JOIN (SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready') e
ON f.id = e.file_id
LEFT JOIN (SELECT file_id, checksum, type
FROM sda.checksums
Expand Down
7 changes: 2 additions & 5 deletions internal/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,7 @@ func TestGetDatasetFileInfo(t *testing.T) {
FROM sda.files f
JOIN sda.file_dataset fd ON fd.file_id = f.id
JOIN sda.datasets d ON fd.dataset_id = d.id
LEFT JOIN \(SELECT file_id,
\(ARRAY_AGG\(event ORDER BY started_at DESC\)\)\[1\] AS event
FROM sda.file_event_log
GROUP BY file_id\) e
LEFT JOIN \(SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready'\) e
ON f.id = e.file_id
LEFT JOIN \(SELECT file_id, checksum, type
FROM sda.checksums
Expand Down Expand Up @@ -439,7 +436,7 @@ func TestGetFiles(t *testing.T) {
FROM sda.files
JOIN sda.file_dataset ON file_id = files.id
JOIN sda.datasets ON file_dataset.dataset_id = datasets.id
LEFT JOIN \(SELECT file_id, \(ARRAY_AGG\(event ORDER BY started_at DESC\)\)\[1\] AS event FROM sda.file_event_log GROUP BY file_id\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, event FROM sda.file_event_log WHERE event = 'ready'\) log ON files.id = log.file_id
LEFT JOIN \(SELECT file_id, checksum, type FROM sda.checksums WHERE source = 'UNENCRYPTED'\) sha ON files.id = sha.file_id
WHERE datasets.stable_id = \$1;
`
Expand Down

0 comments on commit 7e9802b

Please sign in to comment.