Skip to content

Commit

Permalink
🐛 fix minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Dec 6, 2024
1 parent 3dd441d commit 5341641
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 11 additions & 1 deletion adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ import {
addImagesToContentGraph,
updateGdocContentOnly,
upsertGdoc,
updateDerivedGdocPostsComponents,
} from "../db/model/Gdoc/GdocFactory.js"
import { match } from "ts-pattern"
import { GdocDataInsight } from "../db/model/Gdoc/GdocDataInsight.js"
Expand Down Expand Up @@ -2780,6 +2781,11 @@ postRouteWithRWTransaction(
gdoc.createdAt = new Date()
gdoc.publishedAt = post.published_at
await upsertGdoc(trx, gdoc)
await updateDerivedGdocPostsComponents(
trx,
gdoc.id,
gdoc.content.body
)
await setTagsForGdoc(trx, gdocId, tags)
}
return { googleDocsId: gdocId }
Expand Down Expand Up @@ -2981,7 +2987,11 @@ putRouteWithRWTransaction(apiRouter, "/gdocs/:id", async (req, res, trx) => {
)

await upsertGdoc(trx, nextGdoc)

await updateDerivedGdocPostsComponents(
trx,
nextGdoc.id,
nextGdoc.content.body
)
await indexAndBakeGdocIfNeccesary(trx, res.locals.user, prevGdoc, nextGdoc)

return nextGdoc
Expand Down
6 changes: 0 additions & 6 deletions db/model/Gdoc/GdocFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export async function createGdocAndInsertIntoDb(
// loadGdocFromGdocBase().
await upsertGdoc(knex, gdoc)
await updateDerivedGdocPostsComponents(knex, gdoc.id, gdoc.content.body)

return gdoc
}

Expand Down Expand Up @@ -617,11 +616,6 @@ export async function upsertGdoc(
.onConflict("id")
.merge()
sql = query.toSQL()
await updateDerivedGdocPostsComponents(
knex,
enrichedGdoc.id,
enrichedGdoc.content.body
)
return query
} catch (e) {
console.error(`Error occured in sql: ${sql}`, e)
Expand Down

0 comments on commit 5341641

Please sign in to comment.