diff --git a/frontend/src/js/api.ts b/frontend/src/js/api.ts index 679607b..cb65477 100644 --- a/frontend/src/js/api.ts +++ b/frontend/src/js/api.ts @@ -35,7 +35,7 @@ export interface ApiaryAPI { function fakeLoginAttempt(): LoginAttempt { return { - date: randRecentDate({days: 2}).toISOString(), + date: randRecentDate({ days: 2 }).toISOString(), remoteIP: randIp().toString(), username: randUserName().toString(), password: randPassword().toString(), @@ -68,7 +68,9 @@ export class DummyApiaryAPIClient implements ApiaryAPI { } return { name: randUserName().toString(), count: randNumber().valueOf() } }); - return Promise.resolve(stats); + + const sorted = stats.sort((a, b) => b.count - a.count) + return Promise.resolve(sorted); } async query(_type: string, _query: string): Promise { const attempts = Array.from({ length: 10 }, () => { @@ -105,7 +107,7 @@ export class ApiaryAPIClient implements ApiaryAPI { if (!data) { return [] } - return data + return data.sort((a, b) => b.count - a.count) } async query(queryType: string, query: string): Promise { const resp = await fetch(`/api/query?type=${queryType}&query=${query}`) diff --git a/frontend/src/js/app.tsx b/frontend/src/js/app.tsx index 6ed5ba3..88cb0b0 100644 --- a/frontend/src/js/app.tsx +++ b/frontend/src/js/app.tsx @@ -169,6 +169,7 @@ export function StatsPie({ data }: StatsPieProps) { borderWidth: 1 }] }; + console.log(piedata) const getTextColor = () => { return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'white' : 'black' }