Skip to content

Commit

Permalink
filter historical prices date range
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Oct 11, 2024
1 parent b5d9e03 commit a01b395
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions datasources/historical-prices.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ class historicalPricesAPI extends WorkerKVSplit {
let prices = cache.historicalPricePoint[itemId];
if (!prices) {
return [];
}
else if (days === this.maxDays) {
}
/*if (days === this.maxDays) {
return prices;
}*/
const cutoffTimestamp = new Date().setDate(new Date().getDate() - days);
let dayFiltered = prices.filter(hp => hp.timestamp >= cutoffTimestamp);
if (halfResults) {
dayFiltered = dayFiltered.filter((hp, index) => index % 2 === 0);
}
else {
const cutoffTimestamp = new Date().setDate(new Date().getDate() - days);
let dayFiltered = prices.filter(hp => hp.timestamp >= cutoffTimestamp);
if (halfResults) {
dayFiltered = dayFiltered.filter((hp, index) => index % 2 === 0);
}
return dayFiltered;
}
return dayFiltered;
}
}

Expand Down

0 comments on commit a01b395

Please sign in to comment.