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