vault backup: 2023-11-08 09:43:55

This commit is contained in:
Paul Trowbridge 2023-11-08 09:43:55 -05:00
parent 91b309bde4
commit 273521a78e
1 changed files with 18 additions and 8 deletions

26
api.ts
View File

@ -37,14 +37,16 @@ function apply_guidance(doc: any) {
let mostRelevantMarketKey = null; let mostRelevantMarketKey = null;
let mostRelevantMarketSeason = null; let mostRelevantMarketSeason = null;
let mostRelevantMarketSeasonEarly = null; let mostRelevantMarketSeasonEarly = null;
let highestMarketRelevanceLevel = -1; let highestMarketRelevanceLevel = 0;
let mostRelevantMarketSource = null;
let mostRelevantCustomerPriceEarly = null; let mostRelevantCustomerPriceEarly = null;
let mostRelevantCustomerPriceRecent = null; let mostRelevantCustomerPriceRecent = null;
let mostRelevantCustomerKey = null; let mostRelevantCustomerKey = null;
let mostRelevantCustomerSeasonEarly = null; let mostRelevantCustomerSeasonEarly = null;
let mostRelevantCustomerSeasonRecent = null; let mostRelevantCustomerSeasonRecent = null;
let highestCustomerRelevanceLevel = -1; let highestCustomerRelevanceLevel = 0;
let mostRelevantCustomerSource = null;
// Function to update price and assign relevance indicator // Function to update price and assign relevance indicator
function setAnchors(items, channelFirstChar, v1ds, v0ds, histKey) { function setAnchors(items, channelFirstChar, v1ds, v0ds, histKey) {
@ -76,10 +78,12 @@ function apply_guidance(doc: any) {
if (item.v1ds === v1ds) { if (item.v1ds === v1ds) {
marketRelevance = 2; // 'most relevant' because v1ds matches marketRelevance = 2; // 'most relevant' because v1ds matches
// Check for customer relevance if 'cust' key exists // Check for customer relevance if 'cust' key exists
customerRelevance = item.cust ? 2 : 0 customerRelevance = item.cust ? 3 : 0
} else if (item.v0ds === v0ds) { } else if (item.v0ds === v0ds) {
marketRelevance = marketRelevance === 2 ? 2 : 1; // Keep relevance as is if v1ds was matched, otherwise it's just 'relevant' marketRelevance = marketRelevance === 2 ? 2 : 1; // Keep relevance as is if v1ds was matched, otherwise it's just 'relevant'
customerRelevance = item.cust ? 1 : 0 customerRelevance = item.cust ? 2 : 0
} else if (item.cust) {
customerRelevance = item.v1ds ? 2 : item.v0ds ? 1 : 0
} }
} }
@ -93,6 +97,8 @@ function apply_guidance(doc: any) {
mostRelevantMarketPrice = item.last_price; mostRelevantMarketPrice = item.last_price;
mostRelevantMarketPriceEarly = item.early_price; mostRelevantMarketPriceEarly = item.early_price;
mostRelevantMarketKey = histKey; mostRelevantMarketKey = histKey;
mostRelevantMarketSource = item;
delete mostRelevantMarketSource.season;
mostRelevantMarketSeason = item.last_season; // Assuming 'season' is the key where the season info is stored mostRelevantMarketSeason = item.last_season; // Assuming 'season' is the key where the season info is stored
mostRelevantMarketSeasonEarly = item.early_season; mostRelevantMarketSeasonEarly = item.early_season;
} }
@ -103,6 +109,8 @@ function apply_guidance(doc: any) {
mostRelevantCustomerPriceRecent = item.last_price; mostRelevantCustomerPriceRecent = item.last_price;
mostRelevantCustomerPriceEarly = item.early_price; mostRelevantCustomerPriceEarly = item.early_price;
mostRelevantCustomerKey = histKey; mostRelevantCustomerKey = histKey;
mostRelevantCustomerSource = item;
delete mostRelevantCustomerSource.season;
mostRelevantCustomerSeasonRecent = item.last_season; // Assuming 'season' is the key where the season info is stored mostRelevantCustomerSeasonRecent = item.last_season; // Assuming 'season' is the key where the season info is stored
mostRelevantCustomerSeasonEarly = item.early_season; // Assuming 'season' is the key where the season info is stored mostRelevantCustomerSeasonEarly = item.early_season; // Assuming 'season' is the key where the season info is stored
} }
@ -120,9 +128,10 @@ function apply_guidance(doc: any) {
doc.mostRelevantMarketPriceInfo = { doc.mostRelevantMarketPriceInfo = {
price: mostRelevantMarketPrice, price: mostRelevantMarketPrice,
price_early: mostRelevantMarketPriceEarly, price_early: mostRelevantMarketPriceEarly,
histKey: mostRelevantMarketKey, source: mostRelevantMarketSource,
season: mostRelevantMarketSeason, season: mostRelevantMarketSeason,
season_early: mostRelevantMarketSeasonEarly season_early: mostRelevantMarketSeasonEarly,
relevance: highestMarketRelevanceLevel
}; };
} }
@ -131,9 +140,10 @@ function apply_guidance(doc: any) {
doc.mostRelevantCustomerPriceInfo = { doc.mostRelevantCustomerPriceInfo = {
price: mostRelevantCustomerPriceRecent, price: mostRelevantCustomerPriceRecent,
price_early: mostRelevantCustomerPriceEarly, price_early: mostRelevantCustomerPriceEarly,
histKey: mostRelevantCustomerKey, source: mostRelevantCustomerSource,
season: mostRelevantCustomerSeasonRecent, season: mostRelevantCustomerSeasonRecent,
season_early: mostRelevantCustomerSeasonEarly season_early: mostRelevantCustomerSeasonEarly,
relevance: highestCustomerRelevanceLevel
}; };
} }