Skip to content

Commit

Permalink
ixed Nåværende seiersrekke and Lengste seiersrekke
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Lambert committed Jan 12, 2025
1 parent a37fea1 commit d01d2d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/domain/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function getStatsData(): StatsData {
let bestDistanceSum = 0;
for (const [dayStringNew, guesses] of allGuessesEntries) {
bestDistanceSum += Math.min(...guesses.map((guess) => guess.distance));
const currentDate = DateTime.fromFormat(dayStringNew, "dd-MM-yyyy");
const currentDate = DateTime.fromFormat(dayStringNew, "yyyy-MM-dd");
const winIndex = guesses.findIndex((guess) => guess.distance === 0);
const won = winIndex >= 0;
if (won) {
Expand All @@ -56,6 +56,12 @@ export function getStatsData(): StatsData {
previousDate = currentDate;
}

if(previousDate != null &&
!previousDate?.plus({ days: 1 }).hasSame(DateTime.now(), "day") &&
!previousDate?.hasSame(DateTime.now(), "day")) {
currentStreak = 0;
}

const winCount = Object.values(guessDistribution).reduce(
(total, tries) => total + tries
);
Expand Down

0 comments on commit d01d2d9

Please sign in to comment.