| const { PrismaClient } = require('@prisma/client'); |
| const prisma = new PrismaClient(); |
|
|
| async function verify() { |
| console.log("--- Synergy Engine Verification ---"); |
|
|
| try { |
| |
| 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})`); |
|
|
| |
| 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}`); |
|
|
| |
| console.log("Verification logic execution: SUCCESS"); |
| } |
|
|
| } catch (err) { |
| console.error("Verification failed:", err); |
| } finally { |
| await prisma.$disconnect(); |
| } |
| } |
|
|
| verify(); |
|
|