newStaffLDB-API #48
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user