JS Cringe

This commit is contained in:
Emma Ruby 2024-11-24 19:59:50 -06:00
parent 49edc1c344
commit 3f354d2271
3 changed files with 10 additions and 10 deletions

View File

@ -12,7 +12,7 @@ const facilityTypes = {
} as const;
const CZQM_AIRPORTS = ["CYHZ", "CYFC", "CYQM", "CYSJ", "CYZX", "CYYG", "CYYT", "CYQX", "CYYR", "LFVP", "CYQI", "CYAY", "CYDF", "CYJT"];
export const dynamic = 'force-dynamic'
export async function GET() {
try {
const response = await fetch('https://data.vatsim.net/v3/vatsim-data.json');
@ -30,12 +30,12 @@ export async function GET() {
for (const controller of czqmControllers) {
const facilityType = facilityTypes[controller.facility as keyof typeof facilityTypes];
const airport = CZQM_AIRPORTS.find(ap => controller.callsign.startsWith(ap)) || 'CZQM';
await prisma.controllerSession.upsert({
where: {
id: parseInt(controller.cid),
id: parseInt(controller.logon_time.replace("-", "").replace("-", "").replace("T", "")) + controller.cid,
},
create: {
id: parseInt(controller.logon_time.replace("-", "").replace("-", "").replace("T", "")) + controller.cid,
cid: String(controller.cid),
name: controller.name,
callsign: controller.callsign,

View File

@ -22,7 +22,7 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
}
const totalTime = sessions.reduce((acc, session) => {
const duration = new Date(session.last_seen).getTime() - new Date(session.logon_time).getTime();
const duration = new Date(session.lastSeen).getTime() - new Date(session.logonTime).getTime();
return acc + duration;
}, 0);
@ -30,7 +30,7 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
const totalMinutes = Math.floor((totalTime % (1000 * 60 * 60)) / (1000 * 60));
// Get unique positions
const positions = [...new Set(sessions.map(s => s.facility_type))];
const positions = [...new Set(sessions.map(s => s.facilityType))];
return (
<div className="space-y-6 p-6">
@ -86,16 +86,16 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
</TableHeader>
<TableBody>
{sessions.map((session) => (
<TableRow key={`${session.callsign}-${session.last_seen}`}>
<TableRow key={`${session.callsign}-${session.lastSeen}`}>
<TableCell>
{format(new Date(session.logon_time), "MMM d, yyyy")}
{format(new Date(session.logonTime), "MMM d, yyyy")}
</TableCell>
<TableCell>{session.callsign}</TableCell>
<TableCell>{session.facility_type}</TableCell>
<TableCell>{session.facilityType}</TableCell>
<TableCell>{session.airport}</TableCell>
<TableCell>{session.frequency}</TableCell>
<TableCell>
{formatSessionDuration(session.logon_time, session.last_seen)}
{formatSessionDuration(session.logonTime, session.lastSeen)}
</TableCell>
</TableRow>
))}