Skip to content

Commit 09b5623

Browse files
committed
Squashed commit of the following:
commit 82c907d Merge: 307c0cc 8c71fd2 Author: Anji <[email protected]> Date: Tue Oct 14 10:59:11 2025 -0400 Merge branch 'dev-987-asset-usage-limit-offset-pagination' into anji/dev-1013-mirgrate-to-universal-table commit 307c0cc Merge: d1bbb52 6e62f77 Author: Anji <[email protected]> Date: Tue Oct 14 10:58:28 2025 -0400 Merge branch 'dev-987-asset-usage-limit-offset-pagination' into anji/dev-1013-mirgrate-to-universal-table Conflicts: jsapp/js/account/usage/usageProjectBreakdown.tsx commit d1bbb52 Author: Kalvis Kalniņš <[email protected]> Date: Thu Oct 9 18:45:26 2025 +0300 fixup! WIP, BROKEN: query error typing mismatch commit 1314ccc Author: Kalvis Kalniņš <[email protected]> Date: Thu Oct 9 18:40:33 2025 +0300 refactor(UniversalTable): parameterize error type commit 133d677 Author: Anji <[email protected]> Date: Thu Oct 9 11:33:00 2025 -0400 WIP, BROKEN: query error typing mismatch commit bda0843 Author: Leszek <[email protected]> Date: Tue Sep 30 21:04:47 2025 +0200 remove duplicated column commit f175294 Author: Anji <[email protected]> Date: Tue Sep 30 13:44:05 2025 -0400 Add count commit a13fdf4 Author: Anji <[email protected]> Date: Tue Sep 30 13:26:51 2025 -0400 add proper link to project label commit d58cc9f Author: Anji <[email protected]> Date: Thu Sep 25 15:06:54 2025 -0400 WIP title link commit 94f54d6 Merge: 9d98814 4e7c317 Author: Anji Tong <[email protected]> Date: Thu Sep 25 17:23:27 2025 +0000 Merge branch 'dev-987-asset-usage-limit-offset-pagination' into anji/dev-1013-mirgrate-to-universal-table commit 9d98814 Author: Anji <[email protected]> Date: Thu Sep 18 19:22:31 2025 -0400 biome commit 0772fad Author: Anji <[email protected]> Date: Thu Sep 18 19:21:22 2025 -0400 fix(assetUsage): migrate asset usage table commit 3fc4877 Author: Anji <[email protected]> Date: Thu Sep 18 18:58:35 2025 -0400 WIP: table migrated, TODO: remove old code
1 parent 64b18c1 commit 09b5623

File tree

4 files changed

+125
-247
lines changed

4 files changed

+125
-247
lines changed

jsapp/js/UniversalTable/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useMemo } from 'react'
22

33
import type { UseQueryResult } from '@tanstack/react-query'
4+
import type { ErrorObject } from 'schema-utils/declarations/validate'
5+
import type { ErrorDetail } from '#/api/models/errorDetail'
46
import UniversalTableCore from './UniversalTableCore'
57
import type { UniversalTableColumn } from './UniversalTableCore'
68

@@ -44,7 +46,7 @@ export namespace PaginatedListResponse {
4446
}
4547
}
4648

47-
interface UniversalTableProps<Datum, TError = Error> {
49+
interface UniversalTableProps<Datum, TError = Error | ErrorDetail | ErrorObject> {
4850
// Below are props from `UniversalTable` that should come from the parent
4951
// component (these are kind of "configuration" props). The other
5052
// `UniversalTable` props are being handled here internally.
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { fetchGet } from '#/api'
2+
import type { PaginatedResponse } from '#/dataInterface'
23
import { PROJECT_FIELDS } from '#/projects/projectViews/constants'
34
import type { ProjectFieldName } from '#/projects/projectViews/constants'
45
import type { ProjectsTableOrder } from '#/projects/projectsTable/projectsTable'
56

6-
export interface AssetUsage {
7-
count: string
8-
next: string | null
9-
previous: string | null
10-
results: AssetWithUsage[]
11-
}
12-
137
export interface AssetWithUsage {
148
asset: string
15-
uid: string
169
asset__name: string
1710
nlp_usage_current_period: {
1811
total_nlp_asr_seconds: number
@@ -31,14 +24,16 @@ export interface AssetWithUsage {
3124
const ORG_ASSET_USAGE_URL = '/api/v2/organizations/:organization_id/asset_usage/'
3225

3326
export async function getOrgAssetUsage(
34-
pageNumber: number | string,
27+
limit: number,
28+
offset: number,
3529
organizationId: string,
3630
order?: ProjectsTableOrder,
3731
) {
3832
const apiUrl = ORG_ASSET_USAGE_URL.replace(':organization_id', organizationId)
3933

4034
const params = new URLSearchParams({
41-
page: pageNumber.toString(),
35+
limit: limit.toString(),
36+
offset: offset.toString(),
4237
})
4338

4439
if (order?.fieldName && order.direction && (order.direction === 'ascending' || order.direction === 'descending')) {
@@ -47,8 +42,11 @@ export async function getOrgAssetUsage(
4742
params.set('ordering', orderingPrefix + fieldDefinition.apiOrderingName)
4843
}
4944

50-
return fetchGet<AssetUsage>(`${apiUrl}?${params}`, {
51-
includeHeaders: true,
52-
errorMessageDisplay: t('There was an error fetching asset usage data.'),
53-
})
45+
return {
46+
status: 200 as const,
47+
data: await fetchGet<PaginatedResponse<AssetWithUsage>>(`${apiUrl}?${params}`, {
48+
includeHeaders: true,
49+
errorMessageDisplay: t('There was an error fetching asset usage data.'),
50+
}),
51+
}
5452
}

jsapp/js/account/usage/usageProjectBreakdown.module.scss

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -30,88 +30,7 @@
3030
padding: 2%;
3131
}
3232

33-
.root table {
34-
width: 100%;
35-
border-collapse: collapse;
36-
margin-block-end: 60px;
37-
}
38-
39-
.root table th {
40-
padding: 0 8px;
41-
}
42-
43-
.projects {
44-
padding-right: 15%;
45-
padding-left: 8px;
46-
}
47-
48-
.root th {
49-
font-weight: 700;
50-
font-size: 13px;
51-
color: colors.$kobo-gray-700;
52-
text-align: initial;
53-
padding-block: 1.5%;
54-
}
55-
56-
.root tr {
57-
font-weight: 400;
58-
font-size: 16px;
59-
color: colors.$kobo-gray-800;
60-
border-bottom: 1px solid colors.$kobo-gray-300;
61-
}
62-
63-
.root td {
64-
padding: 18px 8px;
65-
}
66-
6733
.link {
6834
color: colors.$kobo-dark-blue;
6935
font-weight: 600;
7036
}
71-
72-
.currentMonth {
73-
font-weight: 600;
74-
}
75-
76-
.pagination {
77-
font-weight: 400;
78-
font-size: 14px;
79-
color: colors.$kobo-gray-800;
80-
position: fixed;
81-
bottom: 20px;
82-
background-color: white;
83-
border: 1px solid colors.$kobo-gray-400;
84-
width: 150px;
85-
border-radius: 4px;
86-
padding: 5px 0;
87-
display: flex;
88-
align-items: center;
89-
height: 36px;
90-
}
91-
92-
.root button {
93-
background: transparent;
94-
border: none;
95-
padding: 0 8px;
96-
color: colors.$kobo-gray-400;
97-
cursor: pointer;
98-
99-
&.active {
100-
color: colors.$kobo-gray-800;
101-
}
102-
}
103-
104-
.range {
105-
padding: 6px;
106-
border-right: 1px solid colors.$kobo-gray-400;
107-
border-left: 1px solid colors.$kobo-gray-400;
108-
flex: 1;
109-
text-align: center;
110-
}
111-
112-
.emptyMessage {
113-
padding: 40px;
114-
font-size: 1.2rem;
115-
justify-content: center;
116-
text-align: center;
117-
}

0 commit comments

Comments
 (0)