refactor: sort desc by date

This commit is contained in:
Methapon2001 2024-07-19 17:41:05 +07:00
parent 6629b21476
commit 16c807b514

View file

@ -71,17 +71,19 @@ export class BackupController extends Controller {
return JSON.parse(data) as { database: Record<string, any>[]; bucket: Record<string, any>[] };
});
return data.database.flatMap((a) =>
a.type === "file"
? {
name: a.key.replace(".sql.gz", "") as string,
databaseSize: a.size as number,
storageSize: data.bucket.find((b) => a.key.replace(".sql.gz", "") === b.prefix)
?.size as number,
timestamp: a.lastModified as string,
}
: [],
);
return data.database
.flatMap((a) =>
a.type === "file"
? {
name: a.key.replace(".sql.gz", "") as string,
databaseSize: a.size as number,
storageSize: data.bucket.find((b) => a.key.replace(".sql.gz", "") === b.prefix)
?.size as number,
timestamp: a.lastModified as string,
}
: [],
)
.reverse();
}
@Get("backup-running-list")