Skip to content

Commit

Permalink
Merge pull request #340 from the-hideout/filter-historical-prices
Browse files Browse the repository at this point in the history
filter historical prices date range
  • Loading branch information
Razzmatazzz authored Oct 21, 2024
2 parents b5d9e03 + 78daf7b commit 0ce7b5d
Show file tree
Hide file tree
Showing 2 changed files with 10 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
2 changes: 2 additions & 0 deletions schema-static.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,8 @@ type Task {
minPlayerLevel: Int
taskRequirements: [TaskStatusRequirement]!
traderRequirements: [RequirementTrader]!
availableDelaySecondsMin: Int
availableDelaySecondsMax: Int
objectives: [TaskObjective]!
startRewards: TaskRewards
finishRewards: TaskRewards
Expand Down

0 comments on commit 0ce7b5d

Please sign in to comment.