mirror of
https://example.com
synced 2024-11-25 00:16:38 +09:00
fix: 🐛 pagination for "/api/channels/followed"
Co-authored-by: takonomura <@takonomura@github.com>
This commit is contained in:
parent
8490b00609
commit
071071663e
1 changed files with 12 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
import { Channels, ChannelFollowings } from "@/models/index.js";
|
import { Channels, ChannelFollowings } from "@/models/index.js";
|
||||||
import { makePaginationQuery } from "../../common/make-pagination-query.js";
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ["channels", "account"],
|
tags: ["channels", "account"],
|
||||||
|
@ -33,11 +32,18 @@ export const paramDef = {
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default define(meta, paramDef, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const query = makePaginationQuery(
|
const query = ChannelFollowings.createQueryBuilder('following').andWhere({ followerId: me.id });
|
||||||
ChannelFollowings.createQueryBuilder(),
|
if (ps.sinceId) {
|
||||||
ps.sinceId,
|
query.andWhere('following."followeeId" > :sinceId', { sinceId: ps.sinceId });
|
||||||
ps.untilId,
|
}
|
||||||
).andWhere({ followerId: me.id });
|
if (ps.untilId) {
|
||||||
|
query.andWhere('following."followeeId" < :untilId', { untilId: ps.untilId });
|
||||||
|
}
|
||||||
|
if (ps.sinceId && !ps.untilId) {
|
||||||
|
query.orderBy('following."followeeId"', 'ASC');
|
||||||
|
} else {
|
||||||
|
query.orderBy('following."followeeId"', 'DESC');
|
||||||
|
}
|
||||||
|
|
||||||
const followings = await query.take(ps.limit).getMany();
|
const followings = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue