bugfixing: add historical data back
This commit is contained in:
parent
a6771db026
commit
1d3fd92bf2
@ -251,7 +251,7 @@ const handleMessage = async (event) => {
|
||||
const loadWorker = async () => {
|
||||
const SyncWorker = await import('./workers/insiderWorker?worker');
|
||||
syncWorker = new SyncWorker.default();
|
||||
syncWorker.postMessage({ message: data?.getInsiderTrading, historicalPrice: data?.getHistoricalPrice?.MAX});
|
||||
syncWorker.postMessage({ message: data?.getInsiderTrading, historicalPrice: data?.getHistoricalPrice});
|
||||
syncWorker.onmessage = handleMessage;
|
||||
|
||||
|
||||
|
||||
@ -121,9 +121,53 @@ export const load = async ({ params }) => {
|
||||
return sums;
|
||||
};
|
||||
|
||||
|
||||
async function historicalPrice() {
|
||||
let output;
|
||||
|
||||
const cachedData = getCache(params.tickerID, 'historicalPrice'+'max');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
timePeriod: 'max',
|
||||
};
|
||||
|
||||
const response = await fetch(apiURL+'/historical-price', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
output = await response?.json() ?? [];
|
||||
|
||||
/*
|
||||
const mapData = (data) => data?.map(({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close
|
||||
}));
|
||||
*/
|
||||
|
||||
setCache(params.tickerID, output, 'historicalPrice'+'max');
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getInsiderTrading: await getInsiderTrading(),
|
||||
getInsiderTradingStatistics: await getInsiderTradingStatistics()
|
||||
getInsiderTradingStatistics: await getInsiderTradingStatistics(),
|
||||
getHistoricalPrice: await historicalPrice()
|
||||
};
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user