aboutsummaryrefslogtreecommitdiff
path: root/app/views/stats/index.phtml
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2025-09-01 17:28:17 -0400
committerGravatar GitHub <noreply@github.com> 2025-09-01 23:28:17 +0200
commitd31f485973f7e38239b59b17fc43e9f3ab64695f (patch)
treec511552920426c91b7dfe9e3b1ac1b0b76b61f78 /app/views/stats/index.phtml
parent1b2293a57ad4c80066b2ba8a2cb0bfedbd699c05 (diff)
fix: add default values on stat processing (#7891)
Before, there was an error when retrieving stats for a user without feeds. Now, there are default values to display empty stats instead of an exception. See #7884 Closes #7884 Changes proposed in this pull request: - add default values when retrieving stat data How to test the feature manually: 1. create a new user 2. connect as the new user 3. display stats 4. validate that there is no errors
Diffstat (limited to 'app/views/stats/index.phtml')
-rw-r--r--app/views/stats/index.phtml6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/views/stats/index.phtml b/app/views/stats/index.phtml
index 88c4f0a3c..542ac487c 100644
--- a/app/views/stats/index.phtml
+++ b/app/views/stats/index.phtml
@@ -112,7 +112,7 @@ function generateColorPalette(int $count): array {
}
// 1. Get all unique category labels and sort them
-$allLabels = array_unique(array_merge($this->feedByCategory['label'], $this->entryByCategory['label']));
+$allLabels = array_unique(array_merge($this->feedByCategory['label'] ?? [], $this->entryByCategory['label'] ?? []));
sort($allLabels); // Ensure consistent order
// 2. Generate a color palette based on the number of unique categories
@@ -123,11 +123,11 @@ $colorMap = array_combine($allLabels, $colorPalette);
// 4. Align data and labels for both charts
$feedData = array_fill_keys($allLabels, 0); // Initialize data with all categories
-foreach ($this->feedByCategory['label'] as $index => $label) {
+foreach ($this->feedByCategory['label'] ?? [] as $index => $label) {
$feedData[$label] = $this->feedByCategory['data'][$index];
}
$entryData = array_fill_keys($allLabels, 0); // Initialize data with all categories
-foreach ($this->entryByCategory['label'] as $index => $label) {
+foreach ($this->entryByCategory['label'] ?? [] as $index => $label) {
$entryData[$label] = $this->entryByCategory['data'][$index];
}