Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# replace ghp_example with your GitHub PAT token
# replace ghp_example with your GitHub PAT token (see README for instructions)
TOKEN=ghp_example

# optional: Add a comma-separated list of GitHub usernames to whitelist (only these users' streaks will be displayed)
# WHITELIST=DenverCoder1

# optional: disable caching (not recommended, may cause rate limit issues)
# DISABLE_CACHE=true
13 changes: 9 additions & 4 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
"exclude_days" => $excludeDaysRaw,
];

// Check for cached stats first (24 hour cache)
$cachedStats = getCachedStats($user, $cacheOptions);
// Check if cache is disabled
$useCache = !isset($_SERVER["DISABLE_CACHE"]) || strtolower($_SERVER["DISABLE_CACHE"]) !== "true";

// Check for cached stats first (24 hour cache) unless cache is disabled
$cachedStats = $useCache ? getCachedStats($user, $cacheOptions) : null;

if ($cachedStats !== null) {
// Use cached stats - instant response!
Expand All @@ -65,8 +68,10 @@
$stats = getContributionStats($contributions, $excludeDays);
}

// Cache the stats for 24 hours
setCachedStats($user, $cacheOptions, $stats);
// Cache the stats for 24 hours unless cache is disabled
if ($useCache) {
setCachedStats($user, $cacheOptions, $stats);
}
}

renderOutput($stats);
Expand Down