newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
Showing only changes of commit c6552489e1 - Show all commits

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;
}