Sort emojis by updatedAt
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
This commit is contained in:
parent
96c748f807
commit
eab77d9225
|
@ -6,7 +6,10 @@ export function makePaginationQuery<T>(
|
|||
untilId?: string,
|
||||
sinceDate?: number,
|
||||
untilDate?: number,
|
||||
timeColumn?: string
|
||||
) {
|
||||
timeColumn = timeColumn ?? "createdAt";
|
||||
|
||||
if (!sinceDate && !untilDate && (sinceId || untilId)) {
|
||||
if (sinceId && untilId) {
|
||||
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
|
||||
|
@ -24,32 +27,32 @@ export function makePaginationQuery<T>(
|
|||
}
|
||||
|
||||
if (sinceDate && untilDate) {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
q.andWhere(`(${q.alias}.${timeColumn}, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
sinceDate: new Date(sinceDate),
|
||||
sinceId: sinceId,
|
||||
});
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
q.andWhere(`(${q.alias}.${timeColumn}, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
untilDate: new Date(untilDate),
|
||||
untilId: untilId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.orderBy(`${q.alias}.${timeColumn}`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
} else if (sinceDate) {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
q.andWhere(`(${q.alias}.${timeColumn}, ${q.alias}.id) > (:sinceDate, :sinceId)`, {
|
||||
sinceDate: new Date(sinceDate),
|
||||
sinceId: sinceId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "ASC");
|
||||
q.orderBy(`${q.alias}.${timeColumn}`, "ASC");
|
||||
q.addOrderBy(`${q.alias}.id`, "ASC");
|
||||
} else if (untilDate) {
|
||||
q.andWhere(`(${q.alias}.createdAt, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
q.andWhere(`(${q.alias}.${timeColumn}, ${q.alias}.id) < (:untilDate, :untilId)`, {
|
||||
untilDate: new Date(untilDate),
|
||||
untilId: untilId,
|
||||
});
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.orderBy(`${q.alias}.${timeColumn}`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
} else {
|
||||
q.orderBy(`${q.alias}.createdAt`, "DESC");
|
||||
q.orderBy(`${q.alias}.${timeColumn}`, "DESC");
|
||||
q.addOrderBy(`${q.alias}.id`, "DESC");
|
||||
}
|
||||
return q;
|
||||
|
|
|
@ -92,6 +92,9 @@ export default define(meta, paramDef, async (ps) => {
|
|||
Emojis.createQueryBuilder("emoji"),
|
||||
ps.sinceId,
|
||||
ps.untilId,
|
||||
undefined,
|
||||
undefined,
|
||||
"updatedAt"
|
||||
).andWhere("emoji.host IS NULL");
|
||||
|
||||
let emojis: Emoji[];
|
||||
|
|
Loading…
Reference in New Issue