postgres DAL + New UI
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// src/dal/postgresdal.js
|
||||
import pg from "pg";
|
||||
|
||||
const pool = new pg.Pool({
|
||||
@@ -20,7 +19,6 @@ function toNumber(v) {
|
||||
return Number.isFinite(n) ? n : undefined;
|
||||
}
|
||||
|
||||
/* Vehicles */
|
||||
|
||||
export async function getVehicles() {
|
||||
const rows = await dbQuery(
|
||||
@@ -71,7 +69,6 @@ export async function getVehicleById(id) {
|
||||
};
|
||||
}
|
||||
|
||||
/* Routes */
|
||||
|
||||
export async function getRoutes() {
|
||||
const rows = await dbQuery(`SELECT data FROM routes ORDER BY route_id`);
|
||||
@@ -89,7 +86,6 @@ export async function getRouteById(routeId) {
|
||||
return rows[0]?.data || null;
|
||||
}
|
||||
|
||||
/* Route paths */
|
||||
|
||||
export async function getRoutePathsMap() {
|
||||
const rows = await dbQuery(`SELECT route_id, path FROM route_paths`);
|
||||
@@ -111,7 +107,6 @@ export async function getRoutePath(routeId) {
|
||||
return rows[0]?.path || null;
|
||||
}
|
||||
|
||||
/* Stations */
|
||||
|
||||
function transformationStationRow(row) {
|
||||
return {
|
||||
@@ -131,7 +126,6 @@ function transformationStationRow(row) {
|
||||
}
|
||||
|
||||
export async function getStationsRaw() {
|
||||
// For compatibility, just return the full array of normalized station rows.
|
||||
const rows = await dbQuery(`SELECT * FROM stations`);
|
||||
return rows;
|
||||
}
|
||||
@@ -143,7 +137,6 @@ export async function getStations() {
|
||||
|
||||
export async function getStopsByRoute(routeId) {
|
||||
if (routeId == null) return [];
|
||||
// lines @> ARRAY[$1]::text[] means: lines contains this value
|
||||
const rows = await dbQuery(
|
||||
`SELECT * FROM stations WHERE lines @> ARRAY[$1]::text[]`,
|
||||
[String(routeId)]
|
||||
@@ -163,3 +156,4 @@ export async function getStationById(id) {
|
||||
return transformationStationRow(rows[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user