if this becomes a resource hog we will move it to the db. no need for it to really be presitant
29 lines
842 B
TypeScript
29 lines
842 B
TypeScript
import { lanes } from "./cyclecountCheck.js";
|
|
|
|
export const getCycleCountCheck = async (
|
|
age: number = 1000,
|
|
type: string = ""
|
|
) => {
|
|
/**
|
|
* Get the lane data based on the age and type
|
|
*/
|
|
|
|
let filteredLanes = lanes.filter((t: any) => t.DaysSinceLast >= age);
|
|
|
|
if (type != "") {
|
|
return {
|
|
sucess: true,
|
|
message: `${filteredLanes.length} lanes that are of type ${type} and have not been cycle counted in the last ${age} days.`,
|
|
data: filteredLanes.filter(
|
|
(t: any) => t.rowType === type.toUpperCase()
|
|
),
|
|
};
|
|
} else {
|
|
return {
|
|
success: true,
|
|
message: `${filteredLanes.length} lanes grabed that have not been cycle counted in the last ${age} days.`,
|
|
data: filteredLanes,
|
|
};
|
|
}
|
|
};
|