vault backup: 2023-11-07 08:54:12
This commit is contained in:
parent
24c3a20d67
commit
28c5bd5c03
11
api.ts
11
api.ts
@ -33,8 +33,10 @@ const query = await Deno.readTextFile("sql/get.pg.sql");
|
|||||||
|
|
||||||
function apply_guidance(doc: any) {
|
function apply_guidance(doc: any) {
|
||||||
let mostRelevantMarketPrice = null;
|
let mostRelevantMarketPrice = null;
|
||||||
|
let mostRelevantMarketPriceEarly = null;
|
||||||
let mostRelevantMarketKey = null;
|
let mostRelevantMarketKey = null;
|
||||||
let mostRelevantMarketSeason = null;
|
let mostRelevantMarketSeason = null;
|
||||||
|
let mostRelevantMarketSeasonEarly = null;
|
||||||
let highestMarketRelevanceLevel = -1;
|
let highestMarketRelevanceLevel = -1;
|
||||||
|
|
||||||
let mostRelevantCustomerPriceEarly = null;
|
let mostRelevantCustomerPriceEarly = null;
|
||||||
@ -74,9 +76,10 @@ 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 : 1
|
customerRelevance = item.cust ? 2 : 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +92,10 @@ function apply_guidance(doc: any) {
|
|||||||
if (marketRelevance > highestMarketRelevanceLevel) {
|
if (marketRelevance > highestMarketRelevanceLevel) {
|
||||||
highestMarketRelevanceLevel = marketRelevance;
|
highestMarketRelevanceLevel = marketRelevance;
|
||||||
mostRelevantMarketPrice = item.last_price;
|
mostRelevantMarketPrice = item.last_price;
|
||||||
|
mostRelevantMarketPriceEarly = item.early_price;
|
||||||
mostRelevantMarketKey = histKey;
|
mostRelevantMarketKey = histKey;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the most relevant customer price if this item's relevance is higher and it has a 'cust' key
|
// 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) {
|
if (mostRelevantMarketPrice !== null) {
|
||||||
doc.mostRelevantMarketPriceInfo = {
|
doc.mostRelevantMarketPriceInfo = {
|
||||||
price: mostRelevantMarketPrice,
|
price: mostRelevantMarketPrice,
|
||||||
|
price_early: mostRelevantMarketPriceEarly,
|
||||||
histKey: mostRelevantMarketKey,
|
histKey: mostRelevantMarketKey,
|
||||||
season: mostRelevantMarketSeason
|
season: mostRelevantMarketSeason,
|
||||||
|
season_early: mostRelevantMarketSeasonEarly
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user