trip) add day/week trip views (#52)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m19s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m19s
Reviewed-on: #52 Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #52.
This commit is contained in:
@@ -600,14 +600,21 @@ function seedCities(db: Database): void {
|
||||
const cities: { name: string; country: string; country_code: string; population: number }[] =
|
||||
JSON.parse(data);
|
||||
let id = 1;
|
||||
db.run('BEGIN');
|
||||
for (const city of cities) {
|
||||
db.run(
|
||||
'INSERT OR IGNORE INTO cities (id, name, country, country_code, population) VALUES (?, ?, ?, ?, ?)',
|
||||
[id++, city.name, city.country, city.country_code, city.population]
|
||||
);
|
||||
}
|
||||
db.run('COMMIT');
|
||||
console.log(`[db] Seeded ${cities.length} cities`);
|
||||
} catch (e) {
|
||||
try {
|
||||
db.run('ROLLBACK');
|
||||
} catch {
|
||||
/* ignore rollback failure */
|
||||
}
|
||||
console.error('[db] Failed to seed cities:', e);
|
||||
}
|
||||
}
|
||||
@@ -622,6 +629,7 @@ function seedAirports(db: Database): void {
|
||||
const lines = data.split('\n').filter((line) => line.trim());
|
||||
let imported = 0;
|
||||
let skipped = 0;
|
||||
db.run('BEGIN');
|
||||
|
||||
for (const line of lines) {
|
||||
// Skip comments
|
||||
@@ -676,9 +684,15 @@ function seedAirports(db: Database): void {
|
||||
skipped++;
|
||||
}
|
||||
}
|
||||
db.run('COMMIT');
|
||||
console.log(`[db] Seeded ${imported} airports from airports.dat (${skipped} skipped)`);
|
||||
return;
|
||||
} catch (_fileError) {
|
||||
try {
|
||||
db.run('ROLLBACK');
|
||||
} catch {
|
||||
/* ignore rollback failure */
|
||||
}
|
||||
// File doesn't exist, fall back to minimal seed only if table is empty
|
||||
const airportsRow = db.get<{ count: number }>('SELECT COUNT(*) as count FROM airports');
|
||||
if ((airportsRow?.count ?? 0) === 0) {
|
||||
@@ -782,6 +796,7 @@ function seedAirports(db: Database): void {
|
||||
];
|
||||
|
||||
let id = 1;
|
||||
db.run('BEGIN');
|
||||
for (const airport of majorAirports) {
|
||||
db.run(
|
||||
`INSERT OR IGNORE INTO airports (id, iata_code, icao_code, name, city, country, country_code, latitude, longitude, timezone)
|
||||
@@ -800,8 +815,14 @@ function seedAirports(db: Database): void {
|
||||
]
|
||||
);
|
||||
}
|
||||
db.run('COMMIT');
|
||||
console.log(`[db] Seeded ${majorAirports.length} airports`);
|
||||
} catch (e) {
|
||||
try {
|
||||
db.run('ROLLBACK');
|
||||
} catch {
|
||||
/* ignore rollback failure */
|
||||
}
|
||||
console.error('[db] Failed to seed airports:', e);
|
||||
}
|
||||
}
|
||||
@@ -816,6 +837,7 @@ function seedAirlines(db: Database): void {
|
||||
const lines = data.split('\n').filter((line) => line.trim());
|
||||
let imported = 0;
|
||||
let skipped = 0;
|
||||
db.run('BEGIN');
|
||||
|
||||
for (const line of lines) {
|
||||
// Skip comments
|
||||
@@ -857,9 +879,15 @@ function seedAirlines(db: Database): void {
|
||||
skipped++;
|
||||
}
|
||||
}
|
||||
db.run('COMMIT');
|
||||
console.log(`[db] Seeded ${imported} airlines from airlines.dat (${skipped} skipped)`);
|
||||
return;
|
||||
} catch (_fileError) {
|
||||
try {
|
||||
db.run('ROLLBACK');
|
||||
} catch {
|
||||
/* ignore rollback failure */
|
||||
}
|
||||
// File doesn't exist, fall back to minimal seed only if table is empty
|
||||
const airlinesRow = db.get<{ count: number }>('SELECT COUNT(*) as count FROM airlines');
|
||||
if ((airlinesRow?.count ?? 0) === 0) {
|
||||
@@ -921,6 +949,7 @@ function seedAirlines(db: Database): void {
|
||||
];
|
||||
|
||||
let id = 1;
|
||||
db.run('BEGIN');
|
||||
for (const airline of majorAirlines) {
|
||||
db.run(
|
||||
`INSERT OR IGNORE INTO airlines (id, iata_code, icao_code, name, country, country_code)
|
||||
@@ -928,8 +957,14 @@ function seedAirlines(db: Database): void {
|
||||
[id++, airline.iata, airline.icao, airline.name, airline.country, airline.country_code]
|
||||
);
|
||||
}
|
||||
db.run('COMMIT');
|
||||
console.log(`[db] Seeded ${majorAirlines.length} airlines`);
|
||||
} catch (e) {
|
||||
try {
|
||||
db.run('ROLLBACK');
|
||||
} catch {
|
||||
/* ignore rollback failure */
|
||||
}
|
||||
console.error('[db] Failed to seed airlines:', e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user