Skip to content

Commit

Permalink
✨ Sort books reverse-chronologically
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Jul 22, 2022
1 parent f1b1fe4 commit ba63961
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/features/update-summary.ts
Expand Up @@ -28,7 +28,7 @@ export const updateSummary = async (
state: "all",
});
debug(`Got ${issues.data.length} issues`);
const api: (BookResult & {
let api: (BookResult & {
state: "reading" | "completed";
issueNumber: number;
startedAt: string;
Expand Down Expand Up @@ -87,6 +87,7 @@ export const updateSummary = async (
});
} else debug(`Unable to find JSON data for #${issue.id}`);
}
api = api.sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime());
await promises.writeFile(join(".", "api.json"), JSON.stringify(api, null, 2) + "\n");
debug("Written api.json file");
debug(`api has length ${api.length}`);
Expand Down

0 comments on commit ba63961

Please sign in to comment.