Skip to content

Commit

Permalink
only download rated non-variant games from lichess
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Oct 21, 2023
1 parent 82310f3 commit e3d5d1a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
46 changes: 23 additions & 23 deletions src/components/common/AccountCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ function AccountCards({
if (session.lichess && session.lichess.account) {
const account = session.lichess.account;
const lichessSession = session.lichess;
const totalGames =
(account.perfs.ultraBullet?.games ?? 0) +
(account.perfs.bullet?.games ?? 0) +
(account.perfs.blitz?.games ?? 0) +
(account.perfs.rapid?.games ?? 0) +
(account.perfs.classical?.games ?? 0);

const stats = [];
const speeds = ["bullet", "blitz", "rapid", "classical"] as const;

for (const speed of speeds) {
const perf = account.perfs[speed];
if (perf) {
stats.push({
value: perf.rating,
label: speed,
diff: perf.prog,
});
}
}

return (
<AccountCard
key={account.id}
Expand All @@ -39,7 +60,7 @@ function AccountCards({
}
title={account.username}
updatedAt={session.updatedAt}
total={account.count.all - account.count.ai}
total={totalGames}
logout={() => {
setSessions((sessions) =>
sessions.filter((s) => s.lichess?.account.id !== account.id)
Expand Down Expand Up @@ -67,28 +88,7 @@ function AccountCards({
)
);
}}
stats={[
{
value: account.perfs.bullet.rating,
label: "Bullet",
diff: account.perfs.bullet.prog,
},
{
value: account.perfs.blitz.rating,
label: "Blitz",
diff: account.perfs.blitz.prog,
},
{
value: account.perfs.rapid.rating,
label: "Rapid",
diff: account.perfs.rapid.prog,
},
{
value: account.perfs.classical.rating,
label: "Classical",
diff: account.perfs.classical.prog,
},
]}
stats={stats}
/>
);
}
Expand Down
28 changes: 14 additions & 14 deletions src/utils/lichess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export type LichessAccount = {
id: string;
username: string;
perfs: {
chess960: LichessPerf;
atomic: LichessPerf;
racingKings: LichessPerf;
ultraBullet: LichessPerf;
blitz: LichessPerf;
kingOfTheHill: LichessPerf;
bullet: LichessPerf;
correspondence: LichessPerf;
horde: LichessPerf;
puzzle: LichessPerf;
classical: LichessPerf;
rapid: LichessPerf;
storm: {
chess960?: LichessPerf;
atomic?: LichessPerf;
racingKings?: LichessPerf;
ultraBullet?: LichessPerf;
blitz?: LichessPerf;
kingOfTheHill?: LichessPerf;
bullet?: LichessPerf;
correspondence?: LichessPerf;
horde?: LichessPerf;
puzzle?: LichessPerf;
classical?: LichessPerf;
rapid?: LichessPerf;
storm?: {
runs: number;
score: number;
};
Expand Down Expand Up @@ -219,7 +219,7 @@ export async function downloadLichess(
timestamp: number | null,
token?: string
) {
let url = `${baseURL}/games/user/${player}`;
let url = `${baseURL}/games/user/${player}?perfType=ultraBullet,bullet,blitz,rapid,classical,correspondence&rated=true`;
if (timestamp) {
url += `?since=${timestamp}`;
}
Expand Down

0 comments on commit e3d5d1a

Please sign in to comment.