Remove limiter, fix find TrainUID by date
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
d15b7c3c7a
commit
4cc6856a76
2
app.js
2
app.js
@ -60,7 +60,7 @@ app.use(
|
|||||||
);
|
);
|
||||||
app.use(express.json()); //JSON Parsing for POST Requests
|
app.use(express.json()); //JSON Parsing for POST Requests
|
||||||
app.use(compression()); // Compress API Data if supported by client
|
app.use(compression()); // Compress API Data if supported by client
|
||||||
app.use(limiter);
|
//app.use(limiter);
|
||||||
app.use(authenticate);
|
app.use(authenticate);
|
||||||
|
|
||||||
// 2023 Rationalisation Routes (/api/v2, /misc)
|
// 2023 Rationalisation Routes (/api/v2, /misc)
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -18,7 +18,7 @@
|
|||||||
"ldbs-json": "^1.2.1",
|
"ldbs-json": "^1.2.1",
|
||||||
"moment-timezone": "^0.5.43",
|
"moment-timezone": "^0.5.43",
|
||||||
"mongodb": "^4.13.0",
|
"mongodb": "^4.13.0",
|
||||||
"nodemailer": "^6.9.1",
|
"nodemailer": "^6.9.9",
|
||||||
"pino": "^8.15.1",
|
"pino": "^8.15.1",
|
||||||
"redis": "^4.6.7",
|
"redis": "^4.6.7",
|
||||||
"zlib": "^1.0.5"
|
"zlib": "^1.0.5"
|
||||||
|
@ -56,10 +56,12 @@ export async function findByTrainUid(
|
|||||||
) {
|
) {
|
||||||
// Set the correct date - whether a date or "now" was passed to function
|
// Set the correct date - whether a date or "now" was passed to function
|
||||||
let queryDate: Date;
|
let queryDate: Date;
|
||||||
if (date instanceof Date) {
|
if (date === 'now') {
|
||||||
|
queryDate = new Date();
|
||||||
|
} else if (date instanceof Date) {
|
||||||
queryDate = date;
|
queryDate = date;
|
||||||
} else {
|
} else {
|
||||||
queryDate = new Date();
|
queryDate = new Date(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build query
|
// Build query
|
||||||
@ -69,6 +71,7 @@ export async function findByTrainUid(
|
|||||||
scheduleEndDate: { $gte: queryDate },
|
scheduleEndDate: { $gte: queryDate },
|
||||||
daysRun: { $in: [getShortDay(queryDate)] },
|
daysRun: { $in: [getShortDay(queryDate)] },
|
||||||
};
|
};
|
||||||
|
logger.debug(query)
|
||||||
const pipeline = getFindByTrainUidPipeline(query);
|
const pipeline = getFindByTrainUidPipeline(query);
|
||||||
|
|
||||||
const result = (await queryAggregate("timetable", pipeline)) as Service[];
|
const result = (await queryAggregate("timetable", pipeline)) as Service[];
|
||||||
@ -82,7 +85,7 @@ export async function findByTrainUid(
|
|||||||
} else {
|
} else {
|
||||||
pis = null;
|
pis = null;
|
||||||
}
|
}
|
||||||
// TODO: Format and return data, the function called is not yet complete
|
console.log(JSON.stringify(services[0]))
|
||||||
return formatTimetableDetail(services[0], pis);
|
return formatTimetableDetail(services[0], pis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +138,8 @@ function filterServices(services: SimpleService[]): SimpleService[] {
|
|||||||
> = {};
|
> = {};
|
||||||
let filteredServices: SimpleService[] = [];
|
let filteredServices: SimpleService[] = [];
|
||||||
|
|
||||||
|
console.log(services)
|
||||||
|
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
const trainUid = service["trainUid"],
|
const trainUid = service["trainUid"],
|
||||||
stpIndicator = service["stpIndicator"];
|
stpIndicator = service["stpIndicator"];
|
||||||
|
Loading…
Reference in New Issue
Block a user