diff --git a/src/lib/components/admin/Analytics/Dashboard.svelte b/src/lib/components/admin/Analytics/Dashboard.svelte index a016970c3..277cb5339 100644 --- a/src/lib/components/admin/Analytics/Dashboard.svelte +++ b/src/lib/components/admin/Analytics/Dashboard.svelte @@ -158,6 +158,11 @@ if (modelOrderBy === 'name') { return modelDirection === 'asc' ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name); } + if (modelOrderBy === 'tokens') { + const aTokens = tokenStats[a.model_id]?.total_tokens ?? 0; + const bTokens = tokenStats[b.model_id]?.total_tokens ?? 0; + return modelDirection === 'asc' ? aTokens - bTokens : bTokens - aTokens; + } return modelDirection === 'asc' ? a.count - b.count : b.count - a.count; }); @@ -167,6 +172,11 @@ const nameB = b.name || b.user_id; return userDirection === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA); } + if (userOrderBy === 'tokens') { + const aTokens = a.total_tokens ?? 0; + const bTokens = b.total_tokens ?? 0; + return userDirection === 'asc' ? aTokens - bTokens : bTokens - aTokens; + } return userDirection === 'asc' ? a.count - b.count : b.count - a.count; }); @@ -329,8 +339,42 @@ {/if} - {$i18n.t('Tokens')} - % + toggleModelSort('tokens')} + > +
+ {$i18n.t('Tokens')} + {#if modelOrderBy === 'tokens'} + + {#if modelDirection === 'asc'}{:else}{/if} + + {:else} + + {/if} +
+ + toggleModelSort('percentage')} + > +
+ % + {#if modelOrderBy === 'percentage'} + + {#if modelDirection === 'asc'}{:else}{/if} + + {:else} + + {/if} +
+ @@ -425,7 +469,24 @@ {/if} - {$i18n.t('Tokens')} + toggleUserSort('tokens')} + > +
+ {$i18n.t('Tokens')} + {#if userOrderBy === 'tokens'} + + {#if userDirection === 'asc'}{:else}{/if} + + {:else} + + {/if} +
+ diff --git a/src/lib/components/admin/Analytics/ModelUsage.svelte b/src/lib/components/admin/Analytics/ModelUsage.svelte index f585b6ebd..a176080b5 100644 --- a/src/lib/components/admin/Analytics/ModelUsage.svelte +++ b/src/lib/components/admin/Analytics/ModelUsage.svelte @@ -114,7 +114,22 @@ {/if} - {$i18n.t('Share')} + toggleSort('percentage')} + > +
+ {$i18n.t('Share')} + {#if orderBy === 'percentage'} + {#if direction === 'asc'}{:else}{/if} + {:else} + + {/if} +
+ diff --git a/src/lib/components/admin/Analytics/UserUsage.svelte b/src/lib/components/admin/Analytics/UserUsage.svelte index 09be24e42..f04022249 100644 --- a/src/lib/components/admin/Analytics/UserUsage.svelte +++ b/src/lib/components/admin/Analytics/UserUsage.svelte @@ -109,7 +109,22 @@ {/if} - {$i18n.t('Share')} + toggleSort('percentage')} + > +
+ {$i18n.t('Share')} + {#if orderBy === 'percentage'} + {#if direction === 'asc'}{:else}{/if} + {:else} + + {/if} +
+