Skip to content

Commit 251366e

Browse files
committed
Fix pilot unique id being to short
1 parent b1e555c commit 251366e

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

apps/ingestion/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async function fetchVatsimData(): Promise<void> {
5757
updateBookingsData();
5858

5959
const init: InitialData = {
60-
pilots: pilotsLong.map((p) => getPilotShort(p)),
60+
pilots: pilotsLong.filter((p) => p.live === "live").map((p) => getPilotShort(p)),
6161
airports: airportsLong.map((a) => getAirportShort(a)),
6262
controllers: controllersMerged,
6363
timestamp: new Date(vatsimData.general.update_timestamp),

apps/ingestion/src/pilot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function getPilotId(pilot: VatsimPilot | VatsimPrefile): string {
216216
.update(`${base}${plan ? `_${variable}` : ""}`)
217217
.digest();
218218
const b64url = digest.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
219-
return b64url.slice(0, 10);
219+
return b64url.slice(0, 16);
220220
}
221221

222222
export function getPilotDelta(): PilotDelta {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Warnings:
3+
4+
- The primary key for the `Pilot` table will be changed. If it partially fails, the table could be left without primary key constraint.
5+
- The primary key for the `Trackpoint` table will be changed. If it partially fails, the table could be left without primary key constraint.
6+
7+
*/
8+
-- DropForeignKey
9+
ALTER TABLE "Trackpoint" DROP CONSTRAINT "Trackpoint_id_fkey";
10+
11+
-- AlterTable
12+
ALTER TABLE "Pilot" DROP CONSTRAINT "Pilot_pkey",
13+
ALTER COLUMN "id" SET DATA TYPE CHAR(16),
14+
ADD CONSTRAINT "Pilot_pkey" PRIMARY KEY ("id");
15+
16+
-- AlterTable
17+
ALTER TABLE "Trackpoint" DROP CONSTRAINT "Trackpoint_pkey",
18+
ALTER COLUMN "id" SET DATA TYPE CHAR(16),
19+
ADD CONSTRAINT "Trackpoint_pkey" PRIMARY KEY ("id");
20+
21+
-- AddForeignKey
22+
ALTER TABLE "Trackpoint" ADD CONSTRAINT "Trackpoint_id_fkey" FOREIGN KEY ("id") REFERENCES "Pilot"("id") ON DELETE CASCADE ON UPDATE CASCADE;

packages/db/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum PilotLiveStatus {
1414
}
1515

1616
model Pilot {
17-
id String @id @db.Char(10)
17+
id String @id @db.Char(16)
1818
cid String
1919
callsign String
2020
latitude Float
@@ -55,7 +55,7 @@ model Pilot {
5555
}
5656

5757
model Trackpoint {
58-
id String @id @db.Char(10)
58+
id String @id @db.Char(16)
5959
points Bytes
6060
created_at DateTime @default(now())
6161

0 commit comments

Comments
 (0)