price_api/cgpt.patch

39 lines
1.2 KiB
Diff

--- old_apply_guidance.js
+++ new_apply_guidance.js
@@ -1,5 +1,6 @@
function apply_guidance(doc: any) {
let mostRelevantMarketPrice = null;
let mostRelevantMarketKey = null;
+ let earliestCustomerPriceSince2020 = null;
let highestMarketRelevanceLevel = -1;
let mostRelevantCustomerPrice = null;
@@ -20,6 +21,15 @@
let customerRelevance = 0; // Assume 0 is 'not relevant'
// ... (rest of the existing logic)
+
+ // Check for the earliest customer price since 2020
+ if (item.cust && item.last_season >= 2020) {
+ if (earliestCustomerPriceSince2020 === null || item.last_season < earliestCustomerPriceSince2020.season) {
+ earliestCustomerPriceSince2020 = {
+ price: item.last_price,
+ season: item.last_season
+ };
+ }
+ }
// ... (rest of the existing logic)
@@ -50,6 +60,10 @@
// ... (rest of the existing logic)
// Assign the most relevant customer price and key to the top level of the document
+ if (earliestCustomerPriceSince2020 !== null) {
+ doc.earliestCustomerPriceSince2020 = earliestCustomerPriceSince2020;
+ }
+
if (mostRelevantCustomerPrice !== null) {
doc.mostRelevantCustomerPriceInfo = {
price: mostRelevantCustomerPrice,