add endpoint
This commit is contained in:
parent
7b58189861
commit
2c0941b659
@ -11,7 +11,8 @@
|
||||
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
||||
|
||||
|
||||
let rawData = data?.getHedgeFunds;
|
||||
let rawData = data?.getAllHedgeFunds;
|
||||
console.log(rawData)
|
||||
let displayList = [];
|
||||
let filterQuery = '';
|
||||
|
||||
@ -54,13 +55,13 @@ let syncWorker: Worker | undefined = undefined;
|
||||
// Handling messages from the worker
|
||||
const handleMessage = async (event) => {
|
||||
const filterData = event.data?.output
|
||||
console.log(filterData)
|
||||
|
||||
if (filterData?.length !== 0) {
|
||||
rawData = filterData;
|
||||
displayList = [...filterData]?.slice(0,20);
|
||||
} else {
|
||||
// Reset to original data if no matches found
|
||||
rawData = data?.getHedgeFunds;
|
||||
rawData = data?.getAllHedgeFunds;
|
||||
displayList = rawData?.slice(0, 20);
|
||||
}
|
||||
};
|
||||
@ -68,7 +69,7 @@ const handleMessage = async (event) => {
|
||||
const loadWorker = async () => {
|
||||
const SyncWorker = await import('./workers/filterQuery?worker');
|
||||
syncWorker = new SyncWorker.default();
|
||||
syncWorker.postMessage({ rawData: data?.getHedgeFunds, filterQuery: filterQuery});
|
||||
syncWorker.postMessage({ rawData: data?.getAllHedgeFunds, filterQuery: filterQuery});
|
||||
syncWorker.onmessage = handleMessage;
|
||||
|
||||
};
|
||||
@ -82,7 +83,7 @@ async function handleInput(event) {
|
||||
await loadWorker();
|
||||
} else {
|
||||
// Reset to original data if filter is empty
|
||||
rawData = data?.getHedgeFunds;
|
||||
rawData = data?.getAllHedgeFunds;
|
||||
displayList = rawData?.slice(0, 20);
|
||||
}
|
||||
}, 500);
|
||||
@ -135,7 +136,7 @@ async function handleInput(event) {
|
||||
|
||||
<body class="w-full max-w-6xl overflow-hidden m-auto">
|
||||
|
||||
<div class="text-sm breadcrumbs ml-4">
|
||||
<div class="text-sm sm:text-[1rem] breadcrumbs ml-4">
|
||||
<ul>
|
||||
<li><a href="/" class="text-gray-300">Home</a></li>
|
||||
<li class="text-gray-300">Hedge Funds</li>
|
||||
|
||||
@ -2,31 +2,35 @@ import { getCache, setCache } from '$lib/store';
|
||||
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
const getHedgeFunds = async () => {
|
||||
let output;
|
||||
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache('getHedgeFunds', 'getHedgeFunds');
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
|
||||
output = (await import('$lib/hedge-funds/all-hedge-funds.json'))?.default;
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getHedgeFunds'
|
||||
setCache('getHedgeFunds', output, 'getHedgeFunds');
|
||||
}
|
||||
|
||||
|
||||
export const load = async ({parent}) => {
|
||||
|
||||
|
||||
return output;
|
||||
};
|
||||
const getAllHedgeFunds = async () => {
|
||||
const cachedData = getCache('', 'getAllHedgeFunds');
|
||||
|
||||
if (cachedData) {
|
||||
return cachedData;
|
||||
}
|
||||
|
||||
const { apiURL, apiKey } = await parent();
|
||||
const response = await fetch(apiURL+'/all-hedge-funds', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey
|
||||
},
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
|
||||
setCache('', output, 'getAllHedgeFunds');
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getHedgeFunds: await getHedgeFunds()
|
||||
getAllHedgeFunds: await getAllHedgeFunds()
|
||||
};
|
||||
};
|
||||
|
||||
@ -841,7 +841,7 @@ onMount(async () => {
|
||||
<div class="flex flex-row items-center">
|
||||
<div class="flex flex-col">
|
||||
<span class="text-blue-400">{item?.symbol?.replace('_',' ')}</span>
|
||||
<span class="text-white">{formatString(item?.securityName)}</span>
|
||||
<span class="text-white text-sm">{formatString(item?.securityName)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!--{item?.firstName} {item?.lastName}-->
|
||||
@ -948,7 +948,7 @@ onMount(async () => {
|
||||
<div class="flex flex-row items-center">
|
||||
<div class="flex flex-col">
|
||||
<span class="text-blue-400 font-medium">{item?.symbol?.replace('_',' ')}</span>
|
||||
<span class="">{item?.securityName?.length > charNumber ? formatString(item?.securityName?.slice(0,charNumber)) + '...' : formatString(item?.securityName)}</span>
|
||||
<span class="text-sm">{item?.securityName?.length > charNumber ? formatString(item?.securityName?.slice(0,charNumber)) + '...' : formatString(item?.securityName)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!--{item?.firstName} {item?.lastName}-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user