Skip to content

Commit

Permalink
fix(gdoc): insert subclass enriched version in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed May 13, 2024
1 parent 068a321 commit 52332f1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions db/model/Gdoc/GdocFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export async function createGdocAndInsertIntoDb(
// 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 @@ -107,8 +106,13 @@ export async function createGdocAndInsertIntoDb(
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()). Otherwise subclass
// enrichments are not present on the Gdoc subclass when loading from the DB
// (GdocsContentSource.Internal), since subclass enrichements are only done
// while fetching the live gdocs (GdocsContentSource.Gdocs) in
// loadFromGdocBase().
await upsertGdoc(knex, gdoc)

return gdoc
}
Expand Down

0 comments on commit 52332f1

Please sign in to comment.