QC Admin - User Menu Ekonomi : Jumlah Pengangguran

This commit is contained in:
2025-09-16 10:11:54 +08:00
parent a5d841bb6b
commit 4ceea5203f
97 changed files with 6023 additions and 3481 deletions

View File

@@ -1,20 +1,59 @@
import prisma from "@/lib/prisma"
/* eslint-disable @typescript-eslint/no-explicit-any */
// /api/berita/findManyPaginated.ts
import prisma from "@/lib/prisma";
import { Context } from "elysia";
const laporanPublikFindMany = async () => {
const laporanPublik = await prisma.laporanPublik.findMany({
async function laporanPublikFindMany(context: Context) {
// Ambil parameter dari query
const page = Number(context.query.page) || 1;
const limit = Number(context.query.limit) || 10;
const search = (context.query.search as string) || "";
const skip = (page - 1) * limit;
// Buat where clause
const where: any = { isActive: true };
// Tambahkan pencarian (jika ada)
if (search) {
where.OR = [
{ judul: { contains: search, mode: "insensitive" } },
{ lokasi: { contains: search, mode: "insensitive" } },
];
}
try {
// Ambil data dan total count secara paralel
const [data, total] = await Promise.all([
prisma.laporanPublik.findMany({
where,
include: {
penanganan: true
penanganan: true,
},
skip,
take: limit,
orderBy: {
tanggalWaktu: 'desc'
}
})
return {
success: true,
data: laporanPublik,
}
tanggalWaktu: "desc",
},
}),
prisma.laporanPublik.count({ where }),
]);
return {
success: true,
message: "Berhasil ambil laporan publik dengan pagination",
data,
page,
limit,
total,
totalPages: Math.ceil(total / limit),
};
} catch (e) {
console.error("Error di findMany paginated:", e);
return {
success: false,
message: "Gagal mengambil data laporan publik",
};
}
}
export default laporanPublikFindMany;