Skip to content

Commit bd3c4aa

Browse files
committed
split historical prices kv
1 parent dc9ff92 commit bd3c4aa

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

datasources/historical-prices.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const WorkerKV = require('../utils/worker-kv');
1+
const WorkerKVSplit = require('../utils/worker-kv-split');
22

3-
class historicalPricesAPI extends WorkerKV {
3+
class historicalPricesAPI extends WorkerKVSplit {
44
constructor(dataSource) {
55
super('historical_price_data', dataSource);
66
this.defaultDays = 7;
@@ -9,8 +9,9 @@ class historicalPricesAPI extends WorkerKV {
99
}
1010

1111
async getByItemId(context, itemId, days = this.defaultDays, halfResults = false) {
12-
await this.init(context);
13-
if (!this.cache) {
12+
await this.init(context, itemId);
13+
const data = await this.getKVData(context, itemId);
14+
if (!data) {
1415
return Promise.reject(new Error('Historical prices cache is empty'));
1516
}
1617

@@ -22,7 +23,7 @@ class historicalPricesAPI extends WorkerKV {
2223
}
2324
}
2425

25-
let prices = this.cache.historicalPricePoint[itemId];
26+
let prices = data.historicalPricePoint[itemId];
2627
if (!prices) {
2728
return [];
2829
}

0 commit comments

Comments
 (0)