performance fix
This commit is contained in:
parent
689238af07
commit
fa2df40340
@ -8,10 +8,10 @@
|
||||
import InfoModal from "$lib/components/InfoModal.svelte";
|
||||
|
||||
export let userTier;
|
||||
export let revenueSegmentation = [];
|
||||
|
||||
let isLoaded = false;
|
||||
|
||||
let revenueSegmentation = [];
|
||||
|
||||
let data = [];
|
||||
let geographicList = [];
|
||||
@ -119,7 +119,7 @@
|
||||
$revenueSegmentationComponent = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
const getRevenueSegmentation = async (ticker) => {
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache(ticker, "getRevenueSegmentation");
|
||||
@ -142,6 +142,7 @@
|
||||
setCache(ticker, revenueSegmentation, "getRevenueSegmentation");
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
$: {
|
||||
if ($stockTicker && typeof window !== "undefined") {
|
||||
@ -151,16 +152,7 @@
|
||||
geographicList = [];
|
||||
totalProductRevenue = 0;
|
||||
totalGeographicRevenue = 0;
|
||||
const ticker = $stockTicker;
|
||||
|
||||
const asyncFunctions = [getRevenueSegmentation(ticker)];
|
||||
Promise.all(asyncFunctions)
|
||||
.then((results) => {
|
||||
prepareData(revenueSegmentation);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("An error occurred:", error);
|
||||
});
|
||||
prepareData(revenueSegmentation);
|
||||
isLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ onMount( async() => {
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<div class="grid gap-4 sm:gap-8 sm:grid-cols-3 text-start">
|
||||
<Card.Root class="sm:col-span-2 overflow-x-scroll overflow-hidden overflow-y-scroll">
|
||||
<Card.Header class="flex flex-row items-center">
|
||||
@ -617,6 +617,9 @@ onMount( async() => {
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
|
||||
@ -3,9 +3,9 @@ import { validateData } from "$lib/utils";
|
||||
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
|
||||
|
||||
export const load = async ({ locals, params }) => {
|
||||
const getQuantStats = async () => {
|
||||
const { apiKey, apiURL } = locals;
|
||||
const { apiKey, apiURL } = locals;
|
||||
|
||||
const getQuantStats = async () => {
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
};
|
||||
@ -25,9 +25,30 @@ export const load = async ({ locals, params }) => {
|
||||
return output;
|
||||
};
|
||||
|
||||
const getRevenueSegmentation = async () => {
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + "/revenue-segmentation", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getQuantStats: await getQuantStats(),
|
||||
getRevenueSegmentation: await getRevenueSegmentation(),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -208,7 +208,7 @@ updateYearRange()
|
||||
<!--Start RevenueSegmentation-->
|
||||
<Lazy>
|
||||
<div class="w-full pt-10 sm:pb-6 sm:pt-6 m-auto {!$revenueSegmentationComponent ? 'hidden' : ''}">
|
||||
<RevenueSegmentation userTier={data?.user?.tier} />
|
||||
<RevenueSegmentation userTier={data?.user?.tier} revenueSegmentation={data?.getRevenueSegmentation}/>
|
||||
</div>
|
||||
</Lazy>
|
||||
<!--End RevenueSegmentation-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user