Skip to content

Commit

Permalink
Fixed number formatting and cleaned names
Browse files Browse the repository at this point in the history
  • Loading branch information
ddxv committed Feb 24, 2024
1 parent e167c4e commit 4b21d2c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion backend/api_app/controllers/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def companies_overview(categories: list[int]) -> TopCompanies:
df = get_top_companies(categories=categories, group_by_parent=False)
mdf = get_top_companies(categories=categories, monthly=True)
monthly_parents = get_top_companies(
categories=categories, monthly=True, group_by_parent=True,
categories=categories,
monthly=True,
group_by_parent=True,
)

total_installs = mdf["total_installs"].to_numpy()[0]
Expand All @@ -35,6 +37,8 @@ def companies_overview(categories: list[int]) -> TopCompanies:
.reset_index()
)

monthly_parents = monthly_parents.rename(columns={"company_name": "name"})

monthly_all["percent"] = monthly_all["installs"] / total_installs
monthly_parents["percent"] = monthly_parents["installs"] / total_installs

Expand Down
18 changes: 13 additions & 5 deletions frontend/src/lib/AdtechTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
function navigate(name: string) {
window.location.href = `/adtech/companies/${name}`;
}
function formatNumber(num: number) {
if (num >= 1000000000000) return (num / 1000000000000).toFixed(1).replace(/\.0$/, '') + 'T';
if (num >= 1000000000) return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'B';
if (num >= 1000000) return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
if (num >= 1000) return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
return num;
}
</script>

<div class="table-container">
Expand All @@ -17,9 +25,9 @@
{#if tableType == 'apps'}
<th><h4 class="h4">App Count</h4></th>
{:else}
<th><h4 class="h4">Installs</h4></th>
<th><h4 class="h4">Total Installs</h4></th>
{/if}
<th><h4 class="h4">Percentage</h4></th>
<th><h4 class="h4">Percent of Total</h4></th>
</tr>
</thead>
<tbody>
Expand All @@ -35,9 +43,9 @@
<td>
<div class="inline-flex">
{#if tableType == 'apps'}
<h3 class="h6 md:h5">{values.app_count}</h3>
{:else}
<h3 class="h6 md:h5">{values.installs}</h3>
<h3 class="h6 md:h5">{formatNumber(values.app_count)}</h3>
{:else if values.installs}
<h3 class="h6 md:h5">{formatNumber(values.installs)}</h3>
{/if}
</div>
</td>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/NavTabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<h3 class={topBarFont}>RANKS</h3>
</TabAnchor>
<TabAnchor
href="/adtech/networks?groupby=brands"
href="/adtech/networks?groupby=brands&time=month"
selected={$page.url.pathname.startsWith('/adtech')}
><h3 class={topBarFont}>ADTECH</h3></TabAnchor
>
Expand Down

0 comments on commit 4b21d2c

Please sign in to comment.