Change the way to get creates data (#223)

This commit is contained in:
zxg 2022-12-02 23:05:25 +08:00 committed by GitHub
parent 9d1602d1e0
commit c5cec9f41c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,7 +41,13 @@ async function refresh(orderBy = "time") {
}
let compat = new Compat();
let cratesData = (await Statistics.load()).cratesData;
const { timeline } = await Statistics.load();
const cratesData = timeline.reduce((pre, [time, type, crate]) => {
if(crate) {
pre[crate] = (pre[crate] || 0) + 1;
}
return pre;
}, Object.create(null));
let crates = Object.entries(await CrateDocManager.getCrates()).map(([name, crate]) => {
return {
name,