Use pagination by date
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
This commit is contained in:
parent
79a7e6c232
commit
a1d8e1ac97
|
@ -7,6 +7,7 @@ export function makePaginationQuery<T>(
|
|||
sinceDate?: number,
|
||||
untilDate?: number,
|
||||
) {
|
||||
if (!sinceDate && !untilDate) {
|
||||
if (sinceId && untilId) {
|
||||
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
|
||||
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
|
||||
|
@ -17,26 +18,39 @@ export function makePaginationQuery<T>(
|
|||
} else if (untilId) {
|
||||
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
|
||||
q.orderBy(`${q.alias}.id`, "DESC");
|
||||
} else if (sinceDate && untilDate) {
|
||||
q.andWhere(`${q.alias}.createdAt > :sinceDate`, {
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
if (sinceDate && untilDate) {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
sinceDate: new Date(sinceDate),
|
||||
sinceId: sinceId,
|
||||
});
|
||||
q.andWhere(`${q.alias}.createdAt < :untilDate`, {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
untilDate: new Date(untilDate),
|
||||
untilId: untilId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
} else if (sinceDate) {
|
||||
q.andWhere(`${q.alias}.createdAt > :sinceDate`, {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
sinceDate: new Date(sinceDate),
|
||||
sinceId: sinceId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "ASC");
|
||||
q.addOrderBy(`${q.alias}.id`, "ASC");
|
||||
} else if (untilDate) {
|
||||
q.andWhere(`${q.alias}.createdAt < :untilDate`, {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
untilDate: new Date(untilDate),
|
||||
untilId: untilId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
} else {
|
||||
q.orderBy(`${q.alias}.id`, "DESC");
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue