mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-27 22:24:14 +00:00
feat: time range select (#29)
Co-authored-by: AlexHelo <itsalexhelo@gmail.com>
This commit is contained in:
parent
b6839c8d21
commit
c14b8d5a93
4 changed files with 111 additions and 84 deletions
|
|
@ -9,7 +9,22 @@ export async function GET(request: NextRequest) {
|
|||
const parsed = searchSchema.safeParse(Object.fromEntries(request.nextUrl.searchParams));
|
||||
if (!parsed.success) return NextResponse.json({ error: parsed.error.issues[0].message }, { status: 400 });
|
||||
|
||||
const { q: query, sort, tags, exclude, platform, gender, makeup, allowCopying, quarantined, page = 1, limit = 24, parentPage, userId } = parsed.data;
|
||||
const {
|
||||
q: query,
|
||||
sort,
|
||||
tags,
|
||||
exclude,
|
||||
platform,
|
||||
gender,
|
||||
makeup,
|
||||
allowCopying,
|
||||
quarantined,
|
||||
page = 1,
|
||||
limit = 24,
|
||||
parentPage,
|
||||
userId,
|
||||
timeRange,
|
||||
} = parsed.data;
|
||||
|
||||
// My Likes page
|
||||
let miiIdsLiked: number[] | undefined = undefined;
|
||||
|
|
@ -55,6 +70,12 @@ export async function GET(request: NextRequest) {
|
|||
...(makeup && { makeup: { equals: makeup } }),
|
||||
// Quarantined
|
||||
...(!quarantined && !userId && { quarantined: false }),
|
||||
// Time range
|
||||
...(timeRange && {
|
||||
createdAt: {
|
||||
gte: new Date(Date.now() - { day: 86400000, week: 604800000, month: 2592000000, year: 31536000000 }[timeRange]),
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const select: Prisma.MiiSelect = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue