fix(transport_helper): add missing fields to db table and some extra

add missing fields to db table
add ref attribute to find routeDetails
also add stationNames to simplify display
This commit is contained in:
fbachus
2026-07-22 03:37:29 +02:00
parent 32d8473086
commit ea0db15877
+14
View File
@@ -779,17 +779,21 @@ class Departure {
static const String tableName = "departure"; static const String tableName = "departure";
int? id; int? id;
String ref;
String vehicleId; String vehicleId;
String vehicleName; String vehicleName;
String stationId; String stationId;
String stationName;
DateTime arrivalTime; DateTime arrivalTime;
DateTime departureTime; DateTime departureTime;
Departure({ Departure({
this.id, this.id,
required this.ref,
required this.vehicleId, required this.vehicleId,
required this.vehicleName, required this.vehicleName,
required this.stationId, required this.stationId,
required this.stationName,
required this.arrivalTime, required this.arrivalTime,
required this.departureTime, required this.departureTime,
}); });
@@ -797,9 +801,11 @@ class Departure {
Map<String, Object?> _toMap() { Map<String, Object?> _toMap() {
return { return {
"id": id, "id": id,
"ref": ref,
"vehicle": vehicleId, "vehicle": vehicleId,
"vehiclename": vehicleName, "vehiclename": vehicleName,
"station": stationId, "station": stationId,
"stationname": stationName,
"arrivaltime": arrivalTime, "arrivaltime": arrivalTime,
"departuretime": departureTime, "departuretime": departureTime,
}; };
@@ -808,9 +814,11 @@ class Departure {
factory Departure.fromMap(Map<String, Object?> map) { factory Departure.fromMap(Map<String, Object?> map) {
return Departure( return Departure(
id: map["id"] as int, id: map["id"] as int,
ref: map["ref"] as String,
vehicleId: map["vehicle"] as String, vehicleId: map["vehicle"] as String,
vehicleName: map["vehiclename"] as String, vehicleName: map["vehiclename"] as String,
stationId: map["station"] as String, stationId: map["station"] as String,
stationName: map["stationname"] as String,
arrivalTime: map["arrivaltime"] as DateTime, arrivalTime: map["arrivaltime"] as DateTime,
departureTime: map["departuretime"] as DateTime, departureTime: map["departuretime"] as DateTime,
); );
@@ -847,9 +855,11 @@ class Departure {
} }
return Departure( return Departure(
ref: json["JourneyDetailRef"]["ref"],
vehicleId: vehicle.id, vehicleId: vehicle.id,
vehicleName: vehicle.name, vehicleName: vehicle.name,
stationId: station.id, stationId: station.id,
stationName: station.name,
arrivalTime: arrivalTime:
arrDateTime ?? arrDateTime ??
depDateTime as DateTime, // one of these has to be in the json depDateTime as DateTime, // one of these has to be in the json
@@ -865,8 +875,12 @@ class Departure {
String station = Station.tableName; String station = Station.tableName;
database.execute("""CREATE TABLE IF NOT EXISTS $tableName( database.execute("""CREATE TABLE IF NOT EXISTS $tableName(
id INTEGER, id INTEGER,
ref TEXT,
vehicle TEXT, vehicle TEXT,
vehiclename TEXT,
station TEXT, station TEXT,
stationname TEXT,
arrivaltime TEXT,
departuretime TEXT, departuretime TEXT,
FOREIGN KEY(vehicle) REFERENCES $vehicle(id), FOREIGN KEY(vehicle) REFERENCES $vehicle(id),
FOREIGN KEY(station) REFERENCES $station(id) FOREIGN KEY(station) REFERENCES $station(id)