Skip to content

Commit f0f2e2b

Browse files
authored
fix: ensure dates in stats are not null (#168)
1 parent 9ba9d10 commit f0f2e2b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/stats.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,19 @@ function getYearJoined(string $user): int
163163
*/
164164
function getContributionStats(array $contributions): array
165165
{
166-
$today = array_key_last($contributions);
166+
$today = array_key_last($contributions) ?? date("Y-m-d");
167+
$first = array_key_first($contributions) ?? date("Y-m-d");
167168
$stats = [
168169
"totalContributions" => 0,
169170
"firstContribution" => "",
170171
"longestStreak" => [
171-
"start" => array_key_first($contributions),
172-
"end" => array_key_first($contributions),
172+
"start" => $first,
173+
"end" => $first,
173174
"length" => 0,
174175
],
175176
"currentStreak" => [
176-
"start" => array_key_first($contributions),
177-
"end" => array_key_first($contributions),
177+
"start" => $first,
178+
"end" => $first,
178179
"length" => 0,
179180
],
180181
];

0 commit comments

Comments
 (0)