56 lines
2.4 KiB
TypeScript
56 lines
2.4 KiB
TypeScript
import db from './src/database/models/index.js';
|
|
import { ParticipantService } from './src/services/ParticipantService.js';
|
|
|
|
async function verify() {
|
|
try {
|
|
console.log('--- Verification Started ---');
|
|
|
|
// 1. Verify Termination Participants
|
|
const termination = await db.TerminationRequest.findOne();
|
|
if (termination) {
|
|
console.log(`Found termination ${termination.id}. Assigning participants...`);
|
|
await ParticipantService.assignTerminationParticipants(termination.id);
|
|
const participants = await db.RequestParticipant.findAll({
|
|
where: { requestId: termination.id, requestType: 'termination' }
|
|
});
|
|
console.log(`Termination Participants added: ${participants.length}`);
|
|
} else {
|
|
console.log('No termination records found to verify.');
|
|
}
|
|
|
|
// 2. Verify Constitutional Participants
|
|
const constitutional = await db.ConstitutionalChange.findOne();
|
|
if (constitutional) {
|
|
console.log(`Found constitutional change ${constitutional.id}. Assigning participants...`);
|
|
await ParticipantService.assignConstitutionalParticipants(constitutional.id);
|
|
const participants = await db.RequestParticipant.findAll({
|
|
where: { requestId: constitutional.id, requestType: 'constitutional' }
|
|
});
|
|
console.log(`Constitutional Participants added: ${participants.length}`);
|
|
} else {
|
|
console.log('No constitutional change records found to verify.');
|
|
}
|
|
|
|
// 3. Verify Resignation Participants
|
|
const resignation = await db.Resignation.findOne();
|
|
if (resignation) {
|
|
console.log(`Found resignation ${resignation.id}. Assigning participants...`);
|
|
await ParticipantService.assignResignationParticipants(resignation.id);
|
|
const participants = await db.RequestParticipant.findAll({
|
|
where: { requestId: resignation.id, requestType: 'resignation' }
|
|
});
|
|
console.log(`Resignation Participants added: ${participants.length}`);
|
|
} else {
|
|
console.log('No resignation records found to verify.');
|
|
}
|
|
|
|
console.log('--- Verification Completed ---');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Verification failed:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
verify();
|