tasks/noc-integration/setup-skills-and-notifications/20260330-1610
This commit is contained in:
22
scripts/check-sync-data.ts
Normal file
22
scripts/check-sync-data.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { prisma } from "../src/utils/db";
|
||||
|
||||
async function check() {
|
||||
console.log("--- Checking Division Data in DB ---");
|
||||
const divisions = await prisma.division.findMany({
|
||||
select: {
|
||||
name: true,
|
||||
externalActivityCount: true,
|
||||
}
|
||||
});
|
||||
console.table(divisions);
|
||||
|
||||
console.log("\n--- Checking API Response for /api/division/ ---");
|
||||
// Mocking the mapping logic from src/api/division.ts
|
||||
const formatted = divisions.map(d => ({
|
||||
name: d.name,
|
||||
activityCount: d.externalActivityCount
|
||||
}));
|
||||
console.table(formatted);
|
||||
}
|
||||
|
||||
check().catch(console.error).finally(() => prisma.$disconnect());
|
||||
@@ -58,12 +58,14 @@ async function syncActiveDivisions() {
|
||||
externalId: extId,
|
||||
color: div.color || "#1E3A5F",
|
||||
villageId: ID_DESA,
|
||||
externalActivityCount: div.totalKegiatan || 0,
|
||||
},
|
||||
create: {
|
||||
externalId: extId,
|
||||
name: name,
|
||||
color: div.color || "#1E3A5F",
|
||||
villageId: ID_DESA,
|
||||
externalActivityCount: div.totalKegiatan || 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user