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
1 change: 0 additions & 1 deletion src/utils/datasetteQueries/endpointAlreadyCollected.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function endpointAlreadyCollectedForDataset ({ endpointUrl, dataset
AND rd.dataset = '${sqlString(dataset)}'
AND ro.organisation = '${sqlString(organisation)}'
AND (e.end_date IS NULL OR e.end_date = '')
AND (r.end_date IS NULL OR r.end_date = '')
LIMIT 1`

const response = await datasette.runQuery(sql)
Expand Down
15 changes: 15 additions & 0 deletions test/unit/utils/endpointAlreadyCollected.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ describe('endpointAlreadyCollectedForDataset', () => {
expect(datasette.runQuery.mock.calls[0][0]).not.toContain('REPLACE')
})

it('does not exclude ended resources from the duplicate endpoint check', async () => {
datasette.runQuery.mockResolvedValue({ formattedData: [] })

await endpointAlreadyCollectedForDataset({
endpointUrl: 'https://example.com/data.csv',
dataset: 'brownfield-land',
organisation: 'local-authority:ABC'
})

const query = datasette.runQuery.mock.calls[0][0]

expect(query).toContain("(e.end_date IS NULL OR e.end_date = '')")
expect(query).not.toContain('r.end_date')
})

it('does not query Datasette when endpoint URL or dataset is missing', async () => {
await expect(endpointAlreadyCollectedForDataset({
endpointUrl: '',
Expand Down
Loading