Refactor decoder to use group name for v3 targets. 1.3.2-alpha.1 release.

This commit is contained in:
Patrick Fic
2024-09-05 13:38:10 -07:00
parent 6467078505
commit fa43424878
7 changed files with 65 additions and 26 deletions

View File

@@ -202,13 +202,13 @@ const generateRemoveQuery = (lineToRemove, index) => {
}`;
};
export const V3TargetAndGroupFinder = (job) => {
export const V3GroupFinder = (job) => {
//Query the Job Targets Database to get one that will match on the Make and Type.
//Using faked data for now.
//TODO - Once verified, replace with real data.
let type = job.v_type === "PC" || job.v_type === "SUV" ? "PC" : job.v_type;
const result = FakedTargetsForV3WithMake.filter((f) => {
const result = FakedGroupsForV3WithMake.filter((f) => {
return (
f.make === job.v_makedesc.toUpperCase() &&
(f.type === type || f.type === null) &&
@@ -232,6 +232,39 @@ export const V3TargetAndGroupFinder = (job) => {
}
};
export const V3TargetFinder = (job) => {
switch (job.group) {
case "Default":
case "Group 1":
return 0.023;
case "Group 2":
return 0.045;
case "Group 3":
return 0.078;
case "Group 4":
return 0.093;
case "Group 5":
return 0.125;
case "Group 6":
return 0.156;
case "Group 7":
return 0.18;
case "Group 8":
return 0.213;
case "Group 9":
return 0.25;
case "Group 10":
return 0.281;
case "Group 11":
return 0.293;
case "Group 12":
return 0.32;
default:
return 0.023;
}
};
const DetermineVehicleGroup = async (job) => {
logger.info(
"Searching for vehicle groups.!",
@@ -243,7 +276,7 @@ const DetermineVehicleGroup = async (job) => {
const RulesetToApply = WhichRulesetToApply(job.close_date);
if (RulesetToApply === "V3") {
const target = V3TargetAndGroupFinder(job);
const target = V3GroupFinder(job);
return target?.group || "Default";
} else {
@@ -297,7 +330,7 @@ const DetermineVehicleType = (job) => {
else return job.v_type;
};
export const FakedTargetsForV3WithMake = [
export const FakedGroupsForV3WithMake = [
{
effective_date: Date("2024-09-01"),
end_date: Date("2050-01-01"),

View File

@@ -194,6 +194,7 @@
"ARMADA",
"TELLURIDE",
"PALLISADE",
"SELTOS",
"TORRENT",
"C-HR",
"SPORTAGE",
@@ -225,5 +226,6 @@
"FJ CRUISER",
"BRONCO SPORT",
"BRONCO SPORT BADLANDS",
"ESCALADE"
"ESCALADE",
"RX 350"
]