JS Cringe
This commit is contained in:
parent
49edc1c344
commit
3f354d2271
@ -12,7 +12,7 @@ const facilityTypes = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const CZQM_AIRPORTS = ["CYHZ", "CYFC", "CYQM", "CYSJ", "CYZX", "CYYG", "CYYT", "CYQX", "CYYR", "LFVP", "CYQI", "CYAY", "CYDF", "CYJT"];
|
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() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://data.vatsim.net/v3/vatsim-data.json');
|
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) {
|
for (const controller of czqmControllers) {
|
||||||
const facilityType = facilityTypes[controller.facility as keyof typeof facilityTypes];
|
const facilityType = facilityTypes[controller.facility as keyof typeof facilityTypes];
|
||||||
const airport = CZQM_AIRPORTS.find(ap => controller.callsign.startsWith(ap)) || 'CZQM';
|
const airport = CZQM_AIRPORTS.find(ap => controller.callsign.startsWith(ap)) || 'CZQM';
|
||||||
|
|
||||||
await prisma.controllerSession.upsert({
|
await prisma.controllerSession.upsert({
|
||||||
where: {
|
where: {
|
||||||
id: parseInt(controller.cid),
|
id: parseInt(controller.logon_time.replace("-", "").replace("-", "").replace("T", "")) + controller.cid,
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
|
id: parseInt(controller.logon_time.replace("-", "").replace("-", "").replace("T", "")) + controller.cid,
|
||||||
cid: String(controller.cid),
|
cid: String(controller.cid),
|
||||||
name: controller.name,
|
name: controller.name,
|
||||||
callsign: controller.callsign,
|
callsign: controller.callsign,
|
||||||
|
@ -22,7 +22,7 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const totalTime = sessions.reduce((acc, session) => {
|
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;
|
return acc + duration;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
|
|||||||
const totalMinutes = Math.floor((totalTime % (1000 * 60 * 60)) / (1000 * 60));
|
const totalMinutes = Math.floor((totalTime % (1000 * 60 * 60)) / (1000 * 60));
|
||||||
|
|
||||||
// Get unique positions
|
// Get unique positions
|
||||||
const positions = [...new Set(sessions.map(s => s.facility_type))];
|
const positions = [...new Set(sessions.map(s => s.facilityType))];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 p-6">
|
<div className="space-y-6 p-6">
|
||||||
@ -86,16 +86,16 @@ export function ControllerProfile({ sessions, loading }: ControllerProfileProps)
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{sessions.map((session) => (
|
{sessions.map((session) => (
|
||||||
<TableRow key={`${session.callsign}-${session.last_seen}`}>
|
<TableRow key={`${session.callsign}-${session.lastSeen}`}>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{format(new Date(session.logon_time), "MMM d, yyyy")}
|
{format(new Date(session.logonTime), "MMM d, yyyy")}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{session.callsign}</TableCell>
|
<TableCell>{session.callsign}</TableCell>
|
||||||
<TableCell>{session.facility_type}</TableCell>
|
<TableCell>{session.facilityType}</TableCell>
|
||||||
<TableCell>{session.airport}</TableCell>
|
<TableCell>{session.airport}</TableCell>
|
||||||
<TableCell>{session.frequency}</TableCell>
|
<TableCell>{session.frequency}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{formatSessionDuration(session.logon_time, session.last_seen)}
|
{formatSessionDuration(session.logonTime, session.lastSeen)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
|
@ -9,7 +9,7 @@ datasource db {
|
|||||||
|
|
||||||
model ControllerSession {
|
model ControllerSession {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
cid String
|
cid String
|
||||||
name String
|
name String
|
||||||
callsign String
|
callsign String
|
||||||
facilityType String
|
facilityType String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user