Skip to content

Commit

Permalink
Fix somes issues with totals of companies
Browse files Browse the repository at this point in the history
  • Loading branch information
ddxv committed Nov 1, 2024
1 parent 14f3818 commit f305e47
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{#snippet card1()}
<WhiteCard>
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Ad Tech Companies</h2>
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Companies</h2>
<p class="text-lg text-gray-700">
<span class="font-semibold text-gray-900"
>{formatNumber(myData.categories.categories.all.total_apps)}</span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ export const csr: boolean = true;

export const load: PageServerLoad = async ({ parent, params }) => {
const networkName = params.name;

const res_parent_categories = fetch(
`http://localhost:8000/api/companies/${networkName}/parentcategories`
);
const res_apps = fetch(`http://localhost:8000/api/companies/${networkName}/topapps`);
const res_sdks = fetch(`http://localhost:8000/api/companies/${networkName}/sdks`);

const { companyDetails, companyTree } = await parent();

const res_parent_categories = fetch(
`http://localhost:8000/api/companies/${networkName}/parentcategories`
);
console.log(`start load overview for company=${networkName}`);
try {
return {
companyDetails: companyDetails,
companyTree: companyTree,
companyTopApps: res_apps
companyParentCategories: res_parent_categories
.then((resp) => {
if (resp.status === 200) {
return resp.json();
} else if (resp.status === 404) {
console.log('Company Not found');
return 'Company Not Found';
console.log('Company Parent Categories Not found');
return 'Company Parent Categories Not Found';
} else if (resp.status === 500) {
console.log('API Server error');
return 'Backend Error';
Expand All @@ -37,13 +37,14 @@ export const load: PageServerLoad = async ({ parent, params }) => {
return 'Uncaught Error';
}
),
companySdks: res_sdks
companyTree: companyTree,
companyTopApps: res_apps
.then((resp) => {
if (resp.status === 200) {
return resp.json();
} else if (resp.status === 404) {
console.log('Company SDKs Not found');
return 'Company SDKs Not Found';
console.log('Company Not found');
return 'Company Not Found';
} else if (resp.status === 500) {
console.log('API Server error');
return 'Backend Error';
Expand All @@ -56,13 +57,13 @@ export const load: PageServerLoad = async ({ parent, params }) => {
return 'Uncaught Error';
}
),
companyParentCategories: res_parent_categories
companySdks: res_sdks
.then((resp) => {
if (resp.status === 200) {
return resp.json();
} else if (resp.status === 404) {
console.log('Company Parent Categories Not found');
return 'Company Parent Categories Not Found';
console.log('Company SDKs Not found');
return 'Company SDKs Not Found';
} else if (resp.status === 500) {
console.log('API Server error');
return 'Backend Error';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@
<CompaniesLayout>
{#snippet card1()}
<WhiteCard>
{#await data.companyDetails}
{#await data.companyParentCategories}
<span class="text-lg text-gray-600">Loading...</span>
{:then myData}
{#if typeof myData == 'string'}
<p class="text-red-500 text-center">Failed to load company details.</p>
{:else if myData.categories.all}
{:else if myData && myData.length > 0}
<div class="bg-white p-2 rounded-lg shadow-md">
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Apps</h2>
<p class="text-lg text-gray-700">
<span class="font-semibold text-gray-900"
>{formatNumber(myData.categories.all.total_apps)}</span
>{formatNumber(myData.map((d) => d.value).reduce((a, b) => a + b, 0))}</span
>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{#snippet card1()}
<WhiteCard>
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Apps</h2>
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Companies</h2>
<p class="text-lg text-gray-700">
<span class="font-semibold text-gray-900"
>{formatNumber(myData.categories.categories.all.total_apps)}</span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{#snippet card1()}
<WhiteCard>
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Ad Tech Companies</h2>
<h2 class="text-xl font-bold text-gray-800 mb-4">Total Companies</h2>
<p class="text-lg text-gray-700">
<span class="font-semibold text-gray-900"
>{formatNumber(myData.categories.categories.all.total_apps)}</span
Expand Down

0 comments on commit f305e47

Please sign in to comment.