vault backup: 2023-11-07 08:54:12

This commit is contained in:
Paul Trowbridge 2023-11-07 08:54:11 -05:00
parent 24c3a20d67
commit 28c5bd5c03

11
api.ts
View File

@ -33,8 +33,10 @@ const query = await Deno.readTextFile("sql/get.pg.sql");
function apply_guidance(doc: any) {
let mostRelevantMarketPrice = null;
let mostRelevantMarketPriceEarly = null;
let mostRelevantMarketKey = null;
let mostRelevantMarketSeason = null;
let mostRelevantMarketSeasonEarly = null;
let highestMarketRelevanceLevel = -1;
let mostRelevantCustomerPriceEarly = null;
@ -74,9 +76,10 @@ function apply_guidance(doc: any) {
if (item.v1ds === v1ds) {
marketRelevance = 2; // 'most relevant' because v1ds matches
// Check for customer relevance if 'cust' key exists
customerRelevance = item.cust ? 2 : 1
customerRelevance = item.cust ? 2 : 0
} else if (item.v0ds === v0ds) {
marketRelevance = marketRelevance === 2 ? 2 : 1; // Keep relevance as is if v1ds was matched, otherwise it's just 'relevant'
customerRelevance = item.cust ? 1 : 0
}
}
@ -89,8 +92,10 @@ function apply_guidance(doc: any) {
if (marketRelevance > highestMarketRelevanceLevel) {
highestMarketRelevanceLevel = marketRelevance;
mostRelevantMarketPrice = item.last_price;
mostRelevantMarketPriceEarly = item.early_price;
mostRelevantMarketKey = histKey;
mostRelevantMarketSeason = item.last_season; // Assuming 'season' is the key where the season info is stored
mostRelevantMarketSeasonEarly = item.early_season;
}
// Update the most relevant customer price if this item's relevance is higher and it has a 'cust' key
@ -115,8 +120,10 @@ function apply_guidance(doc: any) {
if (mostRelevantMarketPrice !== null) {
doc.mostRelevantMarketPriceInfo = {
price: mostRelevantMarketPrice,
price_early: mostRelevantMarketPriceEarly,
histKey: mostRelevantMarketKey,
season: mostRelevantMarketSeason
season: mostRelevantMarketSeason,
season_early: mostRelevantMarketSeasonEarly
};
}