Migrate trainService.service to new logger

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-09-28 14:53:46 +01:00
parent dc9a5e15da
commit c6552489e1

View File

@ -1,15 +1,12 @@
const log = require("../utils/logs.utils");
const db = require("./dbAccess.services");
const clean = require("../utils/sanitizer.utils");
const pis = require("../services/pis.services");
import { logger } from "../utils/logger.utils";
async function findByHeadcodeToday(headcode) {
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
log.out(
"trainServiceServices.findByHeadcode: Searching for headcode " +
sanitizedHeadcode,
"dbug"
);
logger.debug(`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`);
const now = new Date();
const dayMap = ["su", "m", "t", "w", "th", "f", "s"];
const shortDay = dayMap[now.getDay()]; // Fetch short day from map
@ -42,11 +39,7 @@ async function findByHeadcodeToday(headcode) {
async function findByHeadcode(date, headcode) {
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
log.out(
"trainServiceServices.findByHeadcode: Searching for headcode " +
sanitizedHeadcode,
"dbug"
);
logger.debug(`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`);
let searchDate;
if (date === "now") {
searchDate = new Date();
@ -81,7 +74,6 @@ async function findByHeadcode(date, headcode) {
},
];
const queryData = await db.queryAggregate("timetable", pipeline);
console.log(JSON.stringify(queryData));
let filteredData = filterServices(queryData);
return await filteredData;
}