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

26
api.ts
View File

@ -37,14 +37,16 @@ function apply_guidance(doc: any) {
let mostRelevantMarketKey = null;
let mostRelevantMarketSeason = null;
let mostRelevantMarketSeasonEarly = null;
let highestMarketRelevanceLevel = -1;
let highestMarketRelevanceLevel = 0;
let mostRelevantMarketSource = null;
let mostRelevantCustomerPriceEarly = null;
let mostRelevantCustomerPriceRecent = null;
let mostRelevantCustomerKey = null;
let mostRelevantCustomerSeasonEarly = null;
let mostRelevantCustomerSeasonRecent = null;
let highestCustomerRelevanceLevel = -1;
let highestCustomerRelevanceLevel = 0;
let mostRelevantCustomerSource = null;
// Function to update price and assign relevance indicator
function setAnchors(items, channelFirstChar, v1ds, v0ds, histKey) {
@ -76,10 +78,12 @@ 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 : 0
customerRelevance = item.cust ? 3 : 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
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;
mostRelevantMarketPriceEarly = item.early_price;
mostRelevantMarketKey = histKey;
mostRelevantMarketSource = item;
delete mostRelevantMarketSource.season;
mostRelevantMarketSeason = item.last_season; // Assuming 'season' is the key where the season info is stored
mostRelevantMarketSeasonEarly = item.early_season;
}
@ -103,6 +109,8 @@ function apply_guidance(doc: any) {
mostRelevantCustomerPriceRecent = item.last_price;
mostRelevantCustomerPriceEarly = item.early_price;
mostRelevantCustomerKey = histKey;
mostRelevantCustomerSource = item;
delete mostRelevantCustomerSource.season;
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
}
@ -120,9 +128,10 @@ function apply_guidance(doc: any) {
doc.mostRelevantMarketPriceInfo = {
price: mostRelevantMarketPrice,
price_early: mostRelevantMarketPriceEarly,
histKey: mostRelevantMarketKey,
source: mostRelevantMarketSource,
season: mostRelevantMarketSeason,
season_early: mostRelevantMarketSeasonEarly
season_early: mostRelevantMarketSeasonEarly,
relevance: highestMarketRelevanceLevel
};
}
@ -131,9 +140,10 @@ function apply_guidance(doc: any) {
doc.mostRelevantCustomerPriceInfo = {
price: mostRelevantCustomerPriceRecent,
price_early: mostRelevantCustomerPriceEarly,
histKey: mostRelevantCustomerKey,
source: mostRelevantCustomerSource,
season: mostRelevantCustomerSeasonRecent,
season_early: mostRelevantCustomerSeasonEarly
season_early: mostRelevantCustomerSeasonEarly,
relevance: highestCustomerRelevanceLevel
};
}