![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/public_html/scripts/ |
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function testRelationships() {
console.log('š Testing Client-Lawyer Relationship System...\n');
try {
// Get all lawyers
const lawyers = await prisma.user.findMany({
where: {
OR: [
{ role: 'LAWYER' },
{ role: 'ADMIN' }
]
},
select: {
id: true,
name: true,
email: true,
role: true
}
});
console.log(`šØāāļø Found ${lawyers.length} lawyers:`);
lawyers.forEach((lawyer, i) => {
console.log(` ${i + 1}. ${lawyer.name} (${lawyer.email}) - ${lawyer.role}`);
});
// Get all clients
const clients = await prisma.user.findMany({
where: {
role: 'USER'
},
select: {
id: true,
name: true,
email: true,
occupation: true
}
});
console.log(`\nš„ Found ${clients.length} clients:`);
clients.forEach((client, i) => {
console.log(` ${i + 1}. ${client.name} (${client.email}) - ${client.occupation}`);
});
// Get all relationships
const relationships = await prisma.clientLawyerRelationship.findMany({
include: {
client: {
select: {
name: true,
email: true
}
},
lawyer: {
select: {
name: true,
email: true
}
},
case: {
select: {
title: true
}
},
milestones: true,
testimonials: {
where: {
isPublic: true
}
}
}
});
console.log(`\nš¤ Found ${relationships.length} client-lawyer relationships:`);
relationships.forEach((rel, i) => {
console.log(`\n ${i + 1}. ${rel.client.name} ā ${rel.lawyer.name}`);
console.log(` Type: ${rel.relationshipType}`);
console.log(` Status: ${rel.caseStatus || 'N/A'}`);
console.log(` Impact: ${rel.impactLevel || 'N/A'}`);
console.log(` Fee: ${rel.totalFeePaid ? `$${rel.totalFeePaid}` : 'N/A'}`);
console.log(` Settlement: ${rel.settlementAmount ? `$${rel.settlementAmount}` : 'N/A'}`);
console.log(` Satisfaction: ${rel.clientSatisfaction ? `${rel.clientSatisfaction}/5` : 'N/A'}`);
console.log(` Would Recommend: ${rel.wouldRecommend !== null ? (rel.wouldRecommend ? 'Yes' : 'No') : 'N/A'}`);
console.log(` Milestones: ${rel.milestones.length}`);
console.log(` Testimonials: ${rel.testimonials.length}`);
if (rel.case) {
console.log(` Case: ${rel.case.title}`);
}
});
// Get all testimonials
const testimonials = await prisma.clientTestimonial.findMany({
include: {
client: {
select: {
name: true
}
},
lawyer: {
select: {
name: true
}
}
}
});
console.log(`\nā Found ${testimonials.length} testimonials:`);
testimonials.forEach((testimonial, i) => {
console.log(`\n ${i + 1}. "${testimonial.title}"`);
console.log(` By: ${testimonial.client.name}`);
console.log(` About: ${testimonial.lawyer.name}`);
console.log(` Category: ${testimonial.category}`);
console.log(` Impact: ${testimonial.impactLevel}`);
console.log(` Public: ${testimonial.isPublic ? 'Yes' : 'No'}`);
console.log(` Featured: ${testimonial.isFeatured ? 'Yes' : 'No'}`);
console.log(` Views: ${testimonial.views}`);
console.log(` Helpful Votes: ${testimonial.helpfulVotes}`);
});
// Get lawyer stats
const lawyerStats = await prisma.lawyerStats.findMany({
include: {
lawyer: {
select: {
name: true
}
}
}
});
console.log(`\nš Found ${lawyerStats.length} lawyer statistics:`);
lawyerStats.forEach((stat, i) => {
console.log(`\n ${i + 1}. ${stat.lawyer.name}`);
console.log(` Total Clients: ${stat.totalClients}`);
console.log(` Active Clients: ${stat.activeClients}`);
console.log(` Win Rate: ${stat.winRate.toFixed(1)}%`);
console.log(` Cases Won: ${stat.casesWon}`);
console.log(` Cases Settled: ${stat.casesSettled}`);
console.log(` Cases Lost: ${stat.casesLost}`);
console.log(` Total Revenue: $${stat.totalRevenue}`);
console.log(` Pro Bono Hours: ${stat.totalProBonoHours}`);
console.log(` Pro Bono Value: $${stat.totalProBonoValue}`);
console.log(` Avg Satisfaction: ${stat.averageSatisfaction.toFixed(1)}/5`);
console.log(` Recommendation Rate: ${stat.recommendationRate.toFixed(1)}%`);
console.log(` Life-Changing Cases: ${stat.lifeChangingCases}`);
console.log(` Total Settlement Value: $${stat.totalSettlementValue}`);
});
console.log('\nš Relationship system test completed!');
} catch (error) {
console.error('ā Error testing relationships:', error);
}
}
async function main() {
await testRelationships();
await prisma.$disconnect();
}
main().catch((e) => {
console.error(e);
process.exit(1);
});