Added correct timezone
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
182b9560ec
commit
ad8d181ae9
|
|
@ -5,7 +5,7 @@ export default function Home() {
|
||||||
const issRow = db.prepare(`
|
const issRow = db.prepare(`
|
||||||
SELECT pass_time, end_time
|
SELECT pass_time, end_time
|
||||||
FROM iss_passes
|
FROM iss_passes
|
||||||
WHERE datetime(end_time) > datetime('now')
|
WHERE unixepoch(end_time) > unixepoch('now')
|
||||||
ORDER BY datetime(pass_time) ASC LIMIT 1
|
ORDER BY datetime(pass_time) ASC LIMIT 1
|
||||||
`).get() as { pass_time: string, end_time: string } | undefined;
|
`).get() as { pass_time: string, end_time: string } | undefined;
|
||||||
|
|
||||||
|
|
|
||||||
18
lib/db.ts
18
lib/db.ts
|
|
@ -3,15 +3,18 @@ import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const dbDir = isProduction
|
const dbPath = isProduction
|
||||||
? '/app/data'
|
? '/app/data/space_data.db'
|
||||||
: path.resolve(process.cwd(), 'data');
|
: path.resolve(process.cwd(), 'data/space_data.db');
|
||||||
|
|
||||||
|
console.log(`[DB] Using database at: ${dbPath}`);
|
||||||
|
|
||||||
|
// Ensure the directory exists (helps locally)
|
||||||
|
const dbDir = path.dirname(dbPath);
|
||||||
if (!fs.existsSync(dbDir)) {
|
if (!fs.existsSync(dbDir)) {
|
||||||
fs.mkdirSync(dbDir, { recursive: true });
|
fs.mkdirSync(dbDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbPath = path.join(dbDir, 'space_data.db');
|
|
||||||
const db = new Database(dbPath);
|
const db = new Database(dbPath);
|
||||||
|
|
||||||
db.exec(`
|
db.exec(`
|
||||||
|
|
@ -30,6 +33,11 @@ db.exec(`
|
||||||
);
|
);
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const count = db.prepare("SELECT count(*) as total FROM global_events").get() as { total: number };
|
||||||
|
console.log(`[DB] Connected. Found ${count.total} events.`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`[DB] Table not ready yet or empty.`);
|
||||||
|
}
|
||||||
|
|
||||||
export default db;
|
export default db;
|
||||||
Loading…
Reference in a new issue