Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117792699
D1918.1775258584.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D1918.1775258584.diff
View Options
diff --git a/src/app/Http/Controllers/API/V4/Admin/StatsController.php b/src/app/Http/Controllers/API/V4/Admin/StatsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/StatsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/StatsController.php
@@ -105,8 +105,10 @@
while ($weeks > 0) {
$labels[] = $start->format('Y-W');
- $start->subWeeks(1);
$weeks--;
+ if ($weeks) {
+ $start->subWeeks(1);
+ }
}
$labels = array_reverse($labels);
@@ -130,7 +132,7 @@
// $payments = [1000, 1200.25, 3000, 1897.50, 2000, 1900, 2134, 3330];
- $avg = collect($payments)->avg();
+ $avg = collect($payments)->slice(0, count($labels) - 1)->avg();
// See https://frappe.io/charts/docs for format/options description
@@ -171,8 +173,10 @@
while ($weeks > 0) {
$labels[] = $start->format('Y-W');
- $start->subWeeks(1);
$weeks--;
+ if ($weeks) {
+ $start->subWeeks(1);
+ }
}
$labels = array_reverse($labels);
@@ -197,7 +201,7 @@
// $created = [5, 2, 4, 2, 0, 5, 2, 4];
// $deleted = [1, 2, 3, 1, 2, 1, 2, 3];
- $avg = collect($created)->avg();
+ $avg = collect($created)->slice(0, count($labels) - 1)->avg();
// See https://frappe.io/charts/docs for format/options description
@@ -244,8 +248,10 @@
while ($weeks > 0) {
$labels[] = $start->format('Y-W');
- $start->subWeeks(1);
$weeks--;
+ if ($weeks) {
+ $start->subWeeks(1);
+ }
}
$labels = array_reverse($labels);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 11:23 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827249
Default Alt Text
D1918.1775258584.diff (1 KB)
Attached To
Mode
D1918: Fix average value on stats charts to not include current week
Attached
Detach File
Event Timeline