Skip to content

Commit

Permalink
fix(gdocs): save enriched subclass to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed May 6, 2024
1 parent a68d616 commit b23f0f8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions db/model/Gdoc/GdocFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ export async function createGdocAndInsertIntoDb(
knex: KnexReadWriteTransaction,
id: string
): Promise<OwidGdoc> {
// Fetch the data from Google Docs and save it to the database
// Fetch the data from Google Docs.
// We have to fetch it here because we need to know the type of the Gdoc in load()
const base = new GdocBase(id)
await base.fetchAndEnrichGdoc()
await upsertGdoc(knex, base)

// Load its metadata and state so that subclass parsing & validation is also done.
// This involves a second call to the DB and Google, which makes me sad, but it'll do for now.
Expand All @@ -106,9 +105,9 @@ export async function createGdocAndInsertIntoDb(
base,
GdocsContentSource.Gdocs
)

// 2024-03-12 Daniel: We used to save here before the knex refactor but I think that was redundant?
// await gdoc.save()
// Save the enriched Gdoc to the database (including subclass-specific
// enrichments, cf. _enrichSubclassContent())
await upsertGdoc(knex, gdoc)

return gdoc
}
Expand Down

0 comments on commit b23f0f8

Please sign in to comment.