mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Dodano statystki ruchu kolejowego w zakładce Pociągi
This commit is contained in:
@@ -113,6 +113,55 @@ async function getScheduledTrains(stationName: string) {
|
||||
|
||||
return scheduledTrains;
|
||||
}
|
||||
|
||||
async function testLoad() {
|
||||
let scheduledTrains: any[] = [];
|
||||
|
||||
for (let train of onlineTrainsData) {
|
||||
if (train.region !== "eu" || !train.isOnline) continue;
|
||||
|
||||
const timetable = await queryTimetableData(train.trainNo);
|
||||
|
||||
if (!timetable.trainInfo) continue;
|
||||
|
||||
timetable.stopPoints.forEach((point) => {
|
||||
const station = onlineStationsData.find(
|
||||
(online) =>
|
||||
online.stationName
|
||||
.toLowerCase()
|
||||
.includes(point.pointNameRAW.toLowerCase()) ||
|
||||
online.stationName
|
||||
.toLowerCase()
|
||||
.includes(point.pointNameRAW.toLowerCase().split(" ")[0]) ||
|
||||
online.stationName
|
||||
.toLowerCase()
|
||||
.includes(point.pointNameRAW.toLowerCase().split(",")[0])
|
||||
);
|
||||
|
||||
if (!station) return;
|
||||
|
||||
if (!scheduledTrains[station.stationName])
|
||||
scheduledTrains[station.stationName] = [];
|
||||
|
||||
if (
|
||||
scheduledTrains[station.stationName].find(
|
||||
(scheduled) => train.trainNo === scheduled.trainNo
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
scheduledTrains[station.stationName].push({
|
||||
arrivalTime: point?.arrivalTime,
|
||||
departureTime: point?.departureTime,
|
||||
trainCategory: timetable.trainInfo?.trainCategoryCode,
|
||||
trainNo: train.trainNo,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return scheduledTrains;
|
||||
}
|
||||
|
||||
@Module
|
||||
class Store extends VuexModule {
|
||||
private trainCount: number = 0;
|
||||
@@ -122,6 +171,13 @@ class Store extends VuexModule {
|
||||
|
||||
private stations: Station[] = [];
|
||||
|
||||
// private scheduledTrains: {
|
||||
// trainNo: number;
|
||||
// trainCategory: string;
|
||||
// arrivalTime: string;
|
||||
// departureTime: string;
|
||||
// }[] = [];
|
||||
|
||||
private filteredStations: {}[] = [];
|
||||
|
||||
private filterInitStates = {
|
||||
@@ -267,7 +323,7 @@ class Store extends VuexModule {
|
||||
// station.stationName
|
||||
// );
|
||||
|
||||
let scheduledTrains = [];
|
||||
let scheduledTrains: any[] = [];
|
||||
|
||||
return {
|
||||
...stationData,
|
||||
@@ -293,6 +349,18 @@ class Store extends VuexModule {
|
||||
})
|
||||
);
|
||||
|
||||
// const scheduled = await testLoad();
|
||||
|
||||
// for (let stationName in scheduled) {
|
||||
// let t = updatedStations.find(
|
||||
// (updated) => updated.stationName === stationName
|
||||
// );
|
||||
|
||||
// if (!t) continue;
|
||||
|
||||
// t.scheduledTrains = scheduled[stationName];
|
||||
// }
|
||||
|
||||
this.context.commit("updateStations", {
|
||||
updatedStations,
|
||||
trainCount: onlineTrainsData.filter(
|
||||
|
||||
@@ -27,7 +27,11 @@ interface TrainData {
|
||||
}
|
||||
|
||||
interface TimetableResponseData {
|
||||
stopPoints: { pointDistance: number }[] | [];
|
||||
stopPoints: {
|
||||
pointDistance: number;
|
||||
pointNameRAW: string;
|
||||
pointName: string;
|
||||
}[];
|
||||
trainInfo: {
|
||||
timetableId: number;
|
||||
trainCategoryCode: string;
|
||||
@@ -100,6 +104,17 @@ export default class TrainsModule extends VuexModule {
|
||||
? train.dataCon.split(";")[0]
|
||||
: train.dataCon;
|
||||
|
||||
const stopPoints = timetableResponseData?.stopPoints.reduce(
|
||||
(acc, point) => {
|
||||
if (point.pointName.includes("strong")) {
|
||||
acc.push(point.pointNameRAW);
|
||||
}
|
||||
|
||||
return acc;
|
||||
},
|
||||
[] as string[]
|
||||
);
|
||||
|
||||
return {
|
||||
driverId: train.driverId,
|
||||
driverName: train.driverName,
|
||||
@@ -118,7 +133,7 @@ export default class TrainsModule extends VuexModule {
|
||||
timetableId: timetableData && timetableData.timetableId,
|
||||
category: timetableData && timetableData.trainCategoryCode,
|
||||
routeDistance: (timetableData && timetableData.routeDistance) || 0,
|
||||
sceneries: timetableData && timetableData.sceneries,
|
||||
sceneries: stopPoints,
|
||||
TWR: timetableData && timetableData.twr,
|
||||
SKR: timetableData && timetableData.skr,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user