discourse: consolidate parallel `MAX` queries (#1296)
Summary: As mentioned in <https://github.com/sourcecred/sourcecred/pull/1266#discussion_r312345441>. Test Plan: Running `yarn test` passes. wchargin-branch: discourse-single-max-query
This commit is contained in:
parent
b50ba67797
commit
64f282fff2
|
@ -216,17 +216,15 @@ export class Mirror implements DiscourseData {
|
||||||
async update() {
|
async update() {
|
||||||
const db = this._db;
|
const db = this._db;
|
||||||
const latestTopicId = await this._fetcher.latestTopicId();
|
const latestTopicId = await this._fetcher.latestTopicId();
|
||||||
const lastLocalPostId =
|
const {max_post: lastLocalPostId, max_topic: lastLocalTopicId} = db
|
||||||
db
|
.prepare(
|
||||||
.prepare("SELECT MAX(id) FROM posts")
|
dedent`\
|
||||||
.pluck()
|
SELECT
|
||||||
.get() || 0;
|
(SELECT IFNULL(MAX(id), 0) FROM posts) AS max_post,
|
||||||
|
(SELECT IFNULL(MAX(id), 0) FROM topics) AS max_topic
|
||||||
const lastLocalTopicId =
|
`
|
||||||
db
|
)
|
||||||
.prepare("SELECT MAX(id) FROM topics")
|
.get();
|
||||||
.pluck()
|
|
||||||
.get() || 0;
|
|
||||||
|
|
||||||
const encounteredPostIds = new Set();
|
const encounteredPostIds = new Set();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue