revisi: api filter tahun

Deskripsi:
- api filter tahun project dan tugas divisi

No
Issues
This commit is contained in:
2026-02-02 10:14:39 +08:00
parent 97ae638472
commit bf9ef48a70
5 changed files with 117 additions and 2 deletions

View File

@@ -16,6 +16,11 @@ export async function GET(request: Request) {
const page = searchParams.get('page');
const user = searchParams.get('user');
const dataSkip = Number(page) * 10 - 10;
const tahun = searchParams.get("year");
const tahunFilter = tahun ? tahun : new Date().getFullYear().toString();
const startTahun = new Date(`${tahunFilter}-01-01T00:00:00.000Z`);
const endTahun = new Date(`${parseInt(tahunFilter) + 1}-01-01T00:00:00.000Z`);
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
@@ -43,6 +48,10 @@ export async function GET(request: Request) {
title: {
contains: (name == undefined || name == "null") ? "" : name,
mode: "insensitive"
},
createdAt: {
gte: startTahun,
lt: endTahun
}
},
select: {
@@ -87,6 +96,10 @@ export async function GET(request: Request) {
title: {
contains: (name == undefined || name == "null") ? "" : name,
mode: "insensitive"
},
createdAt: {
gte: startTahun,
lt: endTahun
}
}
})