Skip to content

Commit c618b9c

Browse files
committed
sorts for country stats
1 parent 0438696 commit c618b9c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

poliloom-gui/src/app/stats/page.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function CoverageBar({ item }: { item: CountryCoverage }) {
234234
)
235235
}
236236

237-
type SortOrder = 'name' | 'total'
237+
type SortOrder = 'name' | 'total' | 'processed' | 'evaluated'
238238

239239
function CountryCoverageList({ data }: { data: CountryCoverage[] }) {
240240
const [searchQuery, setSearchQuery] = useState('')
@@ -248,11 +248,17 @@ function CountryCoverageList({ data }: { data: CountryCoverage[] }) {
248248

249249
// Sort based on selected order
250250
return [...filtered].sort((a, b) => {
251-
if (sortOrder === 'name') {
252-
return a.name.localeCompare(b.name)
251+
switch (sortOrder) {
252+
case 'name':
253+
return a.name.localeCompare(b.name)
254+
case 'processed':
255+
return b.enriched_count - a.enriched_count
256+
case 'evaluated':
257+
return b.evaluated_count - a.evaluated_count
258+
case 'total':
259+
default:
260+
return b.total_count - a.total_count
253261
}
254-
// Sort by total count descending
255-
return b.total_count - a.total_count
256262
})
257263
}, [data, searchQuery, sortOrder])
258264

@@ -276,6 +282,8 @@ function CountryCoverageList({ data }: { data: CountryCoverage[] }) {
276282
onChange={(value) => setSortOrder(value as SortOrder)}
277283
options={[
278284
{ value: 'total', label: 'Sort by total politicians' },
285+
{ value: 'processed', label: 'Sort by processed' },
286+
{ value: 'evaluated', label: 'Sort by evaluated' },
279287
{ value: 'name', label: 'Sort alphabetically' },
280288
]}
281289
/>

0 commit comments

Comments
 (0)