Skip to content

Commit

Permalink
short-links: Fix two SQL queries for backlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
clbn committed Aug 8, 2023
1 parent 61570cd commit 2326dc0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/support/DbAdapter/backlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const backlinksTrait = (superClass) =>

async updateBacklinks(text, refPostUID, refCommentUID = null, db = this.database) {
const uuids = await db.getCol(
`select long_id from post_short_ids where long_id = any(?) or short_id = any(?)`,
`SELECT long_id FROM post_short_ids WHERE long_id = ANY(?) OR (short_id = ANY(?) AND long_id IS NOT NULL)`,
[extractUUIDs(text), extractShortIds(text)],
);

Expand Down
2 changes: 1 addition & 1 deletion bin/reindex_backlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ process.stdout.write(`\n`);

// Only the real post Short Ids
const shortIdRecords = await dbAdapter.database.getAll(
`select long_id, short_id from post_short_ids where short_id = any(:shortIds)`,
`SELECT long_id, short_id FROM post_short_ids WHERE short_id = ANY(:shortIds) AND long_id IS NOT NULL`,
{
shortIds: [...allShortIds],
},
Expand Down

0 comments on commit 2326dc0

Please sign in to comment.