[mastodon-client] Improve pagination helper function

This commit is contained in:
Laura Hausmann 2023-10-04 23:07:37 +02:00
parent 557dd37fe8
commit bbc0f0278a
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 1 additions and 4 deletions

View File

@ -8,11 +8,9 @@ export class PaginationHelpers {
sinceId?: string,
maxId?: string,
minId?: string,
idField: string = "id",
autoPrefix: boolean = true
idField: string = `${q.alias}.id`,
) {
if (sinceId && minId) throw new Error("Can't user both sinceId and minId params");
if (autoPrefix) idField = `${q.alias}.${idField}`;
if (sinceId && maxId) {
q.andWhere(`${idField} > :sinceId`, {sinceId: sinceId});

View File

@ -167,7 +167,6 @@ export class TimelineHelpers {
maxId,
minId,
"COALESCE(note.threadId, note.id)",
false
)
.distinctOn(["COALESCE(note.threadId, note.id)"])
.orderBy({"COALESCE(note.threadId, note.id)": minId ? "ASC" : "DESC", "note.id": "DESC"})