Skip to content

Commit

Permalink
some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu committed Nov 10, 2023
1 parent 45a1f0e commit 03d1e90
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async function processDocument(
data_source: number,
document_id: string
) {
// These are the versions we want to mark as `deleted` as they precede the `deleted` version we found.
const supersededBeforeData = await core_sequelize.query(
`SELECT * FROM data_sources_documents WHERE data_source = :data_source AND document_id = :document_id AND status = 'superseded' AND created <= :deletedAt`,
{
Expand All @@ -70,6 +71,7 @@ async function processDocument(
}
);

// We check we don't have a latest in there for sanity.
const latestBeforeData = await core_sequelize.query(
`SELECT * FROM data_sources_documents WHERE data_source = :data_source AND document_id = :document_id AND status = 'latest' AND created <= :deletedAt`,
{
Expand All @@ -81,6 +83,7 @@ async function processDocument(
}
);

// Just as FYI is there data after the deletion (the file was deleted and re-upserted)
const afterData = await core_sequelize.query(
`SELECT * FROM data_sources_documents WHERE data_source = :data_source AND document_id = :document_id AND created > :deletedAt`,
{
Expand Down Expand Up @@ -109,6 +112,7 @@ async function processDocument(
);

if (LIVE && supersededBeforeData[0].length > 0) {
// Actually mark as deleted
await core_sequelize.query(
`UPDATE data_sources_documents SET status = 'deleted' WHERE data_source = :data_source AND document_id = :document_id AND status = 'superseded' AND created <= :deletedAt`,
{
Expand Down

0 comments on commit 03d1e90

Please sign in to comment.