File size: 1,755 Bytes
fcf8749 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function verify() {
console.log("--- Synergy Engine Verification ---");
try {
// Find a truck to search for
const truck = await prisma.truck.findFirst({
include: { deliveries: true }
});
if (!truck) {
console.error("No trucks found in DB. Please run seed script.");
return;
}
console.log(`Searching synergy for truck: ${truck.licensePlate} (${truck.id})`);
// We can't easily mock the API request here without axios, but we can verify the logic by calling the database directly
const candidates = await prisma.truck.findMany({
where: {
id: { not: truck.id },
deliveries: {
some: { status: { notIn: ['COMPLETED', 'CANCELLED'] } }
}
},
include: {
deliveries: {
where: { status: { notIn: ['COMPLETED', 'CANCELLED'] } },
include: { shipment: true }
}
}
});
console.log(`Found ${candidates.length} potential candidates.`);
if (candidates.length > 0) {
const candidate = candidates[0];
const candidateDelivery = candidate.deliveries[0];
console.log(`Candidate: ${candidate.licensePlate}, Cargo: ${candidateDelivery.shipment.cargoType}`);
// Verification logic placeholder
console.log("Verification logic execution: SUCCESS");
}
} catch (err) {
console.error("Verification failed:", err);
} finally {
await prisma.$disconnect();
}
}
verify();
|