Sort stats after retrieving from api
This commit is contained in:
parent
2c75603046
commit
db294c171d
@ -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<LoginAttempt[]> {
|
||||
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<LoginAttempt[]> {
|
||||
const resp = await fetch(`/api/query?type=${queryType}&query=${query}`)
|
||||
|
@ -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'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user