Skip to content

Commit 100a6c0

Browse files
committed
Added Line Check to legs. Renamed Line Check for tours to Training Event, to make it more generic.
1 parent f5c833a commit 100a6c0

10 files changed

Lines changed: 73 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
vite.config.js.timestamp-*
88
/library
99
*.bak
10-
.pnpm-store
10+
.pnpm-store
11+
.mcp.json
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- RedefineTables
2+
PRAGMA defer_foreign_keys=ON;
3+
PRAGMA foreign_keys=OFF;
4+
CREATE TABLE "new_legs" (
5+
"id" TEXT NOT NULL PRIMARY KEY,
6+
"dayId" INTEGER,
7+
"route" TEXT,
8+
"useBlock" BOOLEAN NOT NULL,
9+
"positionsFromTracker" BOOLEAN NOT NULL DEFAULT false,
10+
"ident" TEXT,
11+
"originAirportId" TEXT,
12+
"destinationAirportId" TEXT,
13+
"diversionAirportId" TEXT,
14+
"startTime_utc" INTEGER NOT NULL,
15+
"endTime_utc" INTEGER NOT NULL,
16+
"relativeOrder" INTEGER NOT NULL DEFAULT 0,
17+
"totalTime" REAL NOT NULL DEFAULT 0,
18+
"pic" REAL NOT NULL DEFAULT 0,
19+
"sic" REAL NOT NULL DEFAULT 0,
20+
"night" REAL NOT NULL DEFAULT 0,
21+
"solo" REAL NOT NULL DEFAULT 0,
22+
"xc" REAL NOT NULL DEFAULT 0,
23+
"distance" REAL NOT NULL DEFAULT 0,
24+
"dayTakeOffs" INTEGER NOT NULL DEFAULT 0,
25+
"dayLandings" INTEGER NOT NULL DEFAULT 0,
26+
"nightTakeOffs" INTEGER NOT NULL DEFAULT 0,
27+
"nightLandings" INTEGER NOT NULL DEFAULT 0,
28+
"simulatedInstrument" REAL NOT NULL DEFAULT 0,
29+
"actualInstrument" REAL NOT NULL DEFAULT 0,
30+
"holds" INTEGER NOT NULL DEFAULT 0,
31+
"dualGiven" REAL NOT NULL DEFAULT 0,
32+
"dualReceived" REAL NOT NULL DEFAULT 0,
33+
"crossing" BOOLEAN NOT NULL DEFAULT false,
34+
"flightReview" BOOLEAN NOT NULL DEFAULT false,
35+
"checkride" BOOLEAN NOT NULL DEFAULT false,
36+
"ipc" BOOLEAN NOT NULL DEFAULT false,
37+
"faa6158" BOOLEAN NOT NULL DEFAULT false,
38+
"lineCheck" BOOLEAN NOT NULL DEFAULT false,
39+
"passengers" INTEGER NOT NULL DEFAULT 0,
40+
"notes" TEXT NOT NULL DEFAULT '',
41+
"aircraftId" TEXT NOT NULL,
42+
CONSTRAINT "legs_dayId_fkey" FOREIGN KEY ("dayId") REFERENCES "days" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
43+
CONSTRAINT "legs_originAirportId_fkey" FOREIGN KEY ("originAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
44+
CONSTRAINT "legs_destinationAirportId_fkey" FOREIGN KEY ("destinationAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
45+
CONSTRAINT "legs_diversionAirportId_fkey" FOREIGN KEY ("diversionAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
46+
CONSTRAINT "legs_aircraftId_fkey" FOREIGN KEY ("aircraftId") REFERENCES "aircraft" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
47+
);
48+
INSERT INTO "new_legs" ("actualInstrument", "aircraftId", "checkride", "crossing", "dayId", "dayLandings", "dayTakeOffs", "destinationAirportId", "distance", "diversionAirportId", "dualGiven", "dualReceived", "endTime_utc", "faa6158", "flightReview", "holds", "id", "ident", "ipc", "night", "nightLandings", "nightTakeOffs", "notes", "originAirportId", "passengers", "pic", "positionsFromTracker", "relativeOrder", "route", "sic", "simulatedInstrument", "solo", "startTime_utc", "totalTime", "useBlock", "xc") SELECT "actualInstrument", "aircraftId", "checkride", "crossing", "dayId", "dayLandings", "dayTakeOffs", "destinationAirportId", "distance", "diversionAirportId", "dualGiven", "dualReceived", "endTime_utc", "faa6158", "flightReview", "holds", "id", "ident", "ipc", "night", "nightLandings", "nightTakeOffs", "notes", "originAirportId", "passengers", "pic", "positionsFromTracker", "relativeOrder", "route", "sic", "simulatedInstrument", "solo", "startTime_utc", "totalTime", "useBlock", "xc" FROM "legs";
49+
DROP TABLE "legs";
50+
ALTER TABLE "new_legs" RENAME TO "legs";
51+
ALTER TABLE "tours" RENAME COLUMN "lineCheck" TO "trainingEvent";
52+
53+
PRAGMA foreign_keys=ON;
54+
PRAGMA defer_foreign_keys=OFF;

prisma/schema.prisma

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ model Tour {
100100
endAirport Airport? @relation("endAirport", fields: [endAirportId], references: [id], onDelete: Restrict)
101101
102102
companyId String
103-
lineCheck Boolean
103+
trainingEvent Boolean
104104
105105
notes String @default("") // @db.VarChar(1024)
106106
@@ -295,6 +295,7 @@ model Leg {
295295
checkride Boolean @default(false)
296296
ipc Boolean @default(false)
297297
faa6158 Boolean @default(false)
298+
lineCheck Boolean @default(false)
298299
299300
passengers Int @default(0)
300301

src/routes/entry/leg/[id]/+page.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { fetchLegsForSideMenu } from '$lib/server/lib/leg';
1515
import type { Types as DeckTypes } from '$lib/components/map/deck';
1616
import { incrementDataVersion } from '$lib/server/pdf';
1717

18-
// TODO: Calculate sunset and sunrise time for this day in local and Zulu time and display
1918

2019
// Number of values to filter out for the average speed
2120
const AVG_FILTER_NUM = 2;
@@ -502,6 +501,7 @@ export const actions = {
502501
// -----------------------------------------------------------------------------------------------------------------
503502
// Other
504503
// -----------------------------------------------------------------------------------------------------------------
504+
let lineCheck = data.get('line-check') as string | null === 'true' ? true : false;
505505
let flightReview = data.get('flight-review') as string | null === 'true' ? true : false;
506506
let checkride = data.get('checkride') as string | null === 'true' ? true : false;
507507
let ipc = data.get('ipc') as string | null === 'true' ? true : false;
@@ -540,6 +540,7 @@ export const actions = {
540540

541541
holds: holds === null ? undefined : parseInt(holds),
542542

543+
lineCheck: lineCheck,
543544
flightReview: flightReview,
544545
checkride: checkride,
545546
ipc: ipc,

src/routes/entry/leg/[id]/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@
701701
<Entry.FlightTime title="Dual Given" name="dual-given-time" bind:autoFill={totalTime} defaultValue={data.leg.dualGiven} />
702702
<Entry.FlightTime title="Dual Received" name="dual-received-time" bind:autoFill={totalTime} defaultValue={data.leg.dualReceived} />
703703
<Entry.Switch title="Crossing" name="crossing" defaultValue={data.leg.crossing} />
704+
<Entry.Switch title="Line Check (AQP)" name="line-check" defaultValue={data.leg.lineCheck} />
704705
<Entry.Switch title="Flight Review" name="flight-review" defaultValue={data.leg.flightReview} />
705706
<Entry.Switch title="Checkride" name="checkride" defaultValue={data.leg.checkride} />
706707
<Entry.Switch title="IPC" name="ipc" defaultValue={data.leg.ipc} />

src/routes/entry/leg/create/form/+page.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ export const actions = {
415415
// -----------------------------------------------------------------------------------------------------------------
416416
// Other
417417
// -----------------------------------------------------------------------------------------------------------------
418+
let lineCheck = data.get('line-check') as string | null === 'true' ? true : false;
418419
let flightReview = data.get('flight-review') as string | null === 'true' ? true : false;
419420
let checkride = data.get('checkride') as string | null === 'true' ? true : false;
420421
let ipc = data.get('ipc') as string | null === 'true' ? true : false;
@@ -458,6 +459,7 @@ export const actions = {
458459

459460
holds: holds === null ? undefined : parseInt(holds),
460461

462+
lineCheck: lineCheck,
461463
flightReview: flightReview,
462464
checkride: checkride,
463465
ipc: ipc,

src/routes/entry/leg/create/form/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
<Entry.FlightTime title="Dual Received" name="dual-received-time" bind:autoFill={totalTime} defaultValue={null} />
260260
<Entry.Switch title="Crossing" name="crossing" defaultValue={false} />
261261
<!-- <Entry.FlightTime title="Simulated Flight" name="sim-time" bind:autoFill={totalTime} defaultValue={selectedAircraftAPI !== null && selectedAircraftAPI.simulator === true ? (totalTime === null ? null : parseFloat(totalTime)) : null} /> -->
262+
<Entry.Switch title="Line Check (AQP)" name="line-check" defaultValue={false} />
262263
<Entry.Switch title="Flight Review" name="flight-review" defaultValue={false} />
263264
<Entry.Switch title="Checkride" name="checkride" defaultValue={false} />
264265
<Entry.Switch title="IPC" name="ipc" defaultValue={false} />

src/routes/entry/tour/[id]/+page.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export const actions = {
234234
const endTimeTZ = data.get('end-time-tz') as null | string;
235235

236236
const company = data.get('company') as null | 'true' | 'false';
237-
const lineCheck = data.get('line-check') as null | 'true' | 'false';
237+
const trainingEvent = data.get('training-event') as null | 'true' | 'false';
238238

239239
const notes = data.get('notes') as null | string;
240240

@@ -243,7 +243,7 @@ export const actions = {
243243
if (showTime === null || showTime === '') return API.Form.formFailure('?/default', 'show-time', 'Required field');
244244
if (showTimeTZ === null || showTimeTZ === '') return API.Form.formFailure('?/default', 'show-time', 'Required field');
245245
if (company === null || company as string === '') return API.Form.formFailure('?/default', 'company', 'Required field');
246-
if (lineCheck === null || lineCheck as string === '') return API.Form.formFailure('?/default', 'line-check', 'Required field');
246+
if (trainingEvent === null || trainingEvent as string === '') return API.Form.formFailure('?/default', 'training-event', 'Required field');
247247

248248
const showUtc = helpers.timeStrAndTimeZoneToUTC(showTime, showTimeTZ);
249249
if (showUtc === null) return API.Form.formFailure('?/default', 'show-time', 'Unknown Timezone');
@@ -287,7 +287,7 @@ export const actions = {
287287
startTimezoneOffset: showUtc.raw.rawOffsetInMinutes,
288288
startAirportId: showAirport,
289289
companyId: company,
290-
lineCheck: lineCheck === 'true',
290+
trainingEvent: trainingEvent === 'true',
291291
notes: notes ?? undefined
292292
}
293293
});
@@ -319,7 +319,7 @@ export const actions = {
319319
endTimezoneOffset: endUtc.raw.rawOffsetInMinutes,
320320
endAirportId: endAirport,
321321
companyId: company,
322-
lineCheck: lineCheck === 'true',
322+
trainingEvent: trainingEvent === 'true',
323323
notes: notes ?? undefined
324324
}
325325
});
@@ -334,7 +334,7 @@ export const actions = {
334334
startTimezoneOffset: showUtc.raw.rawOffsetInMinutes,
335335
startAirportId: showAirport,
336336
companyId: company,
337-
lineCheck: lineCheck === 'true',
337+
trainingEvent: trainingEvent === 'true',
338338
notes: notes ?? undefined
339339
}
340340
});

src/routes/entry/tour/[id]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234

235235
<Section title="Details">
236236
<Entry.Select required={true} title="Company" options={['NetJets', 'Cape Air']} placeholder="Unset" name="company" defaultValue={data.currentTour?.companyId ?? 'NetJets'} />
237-
<Entry.Switch required={true} title="Line Check" name="line-check" defaultValue={data.currentTour?.lineCheck ?? false} />
237+
<Entry.Switch required={true} title="Training Event" name="training-event" defaultValue={data.currentTour?.trainingEvent ?? false} />
238238
</Section>
239239
<Section title="Notes">
240240
<Entry.TextField name="notes" placeholder="Enter Notes" defaultValue={data.currentTour?.notes ?? null} />

src/routes/entry/tour/[id]/end/+page.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const actions = {
6060
const endTimeTZ = data.get('end-time-tz') as null | string;
6161

6262
const company = data.get('company') as null | 'true' | 'false';
63-
const lineCheck = data.get('line-check') as null | 'true' | 'false';
63+
const trainingEvent = data.get('training-event') as null | 'true' | 'false';
6464

6565
const notes = data.get('notes') as null | string;
6666

@@ -73,7 +73,7 @@ export const actions = {
7373
if (endTime === null || endTime === '') return API.Form.formFailure('?/default', 'end-time', 'Required field');
7474
if (endTimeTZ === null || endTimeTZ === '') return API.Form.formFailure('?/default', 'end-time', 'Required field');
7575
if (company === null || company as string === '') return API.Form.formFailure('?/default', 'company', 'Required field');
76-
if (lineCheck === null || lineCheck as string === '') return API.Form.formFailure('?/default', 'line-check', 'Required field');
76+
if (trainingEvent === null || trainingEvent as string === '') return API.Form.formFailure('?/default', 'training-event', 'Required field');
7777

7878

7979
const showUtc = helpers.timeStrAndTimeZoneToUTC(showTime, showTimeTZ);
@@ -123,7 +123,7 @@ export const actions = {
123123
endTimezoneOffset: endUtc.raw.rawOffsetInMinutes,
124124
endAirportId: endAirport,
125125
companyId: company,
126-
lineCheck: lineCheck === 'true',
126+
trainingEvent: trainingEvent === 'true',
127127
notes: notes ?? undefined
128128
}
129129
});

0 commit comments

Comments
 (0)