Skip to content

Commit 710ffc5

Browse files
committed
## 14.14.0 - 2023-09-22
1 parent d22c052 commit 710ffc5

File tree

5 files changed

+7
-55
lines changed

5 files changed

+7
-55
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## 14.14.0 - 2023-09-22
9+
10+
### Changed
11+
- Revert `percent` value from `Charts`
12+
813
## 14.13.0 - 2023-09-21
914

1015
### Changed

src/Metrics/Chartable.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ private function groupByDays(Builder $builder, string $value, $startDate = null,
5353

5454
$days = $startDate->diffInDays($stopDate) + 1;
5555

56-
$sumValues = $query->sum('value');
57-
58-
return TimeCollection::times($days, function () use ($startDate, $query, $sumValues) {
56+
return TimeCollection::times($days, function () use ($startDate, $query) {
5957
$found = $query->firstWhere(
6058
'label',
6159
$startDate->startOfDay()->toDateString()
@@ -64,7 +62,6 @@ private function groupByDays(Builder $builder, string $value, $startDate = null,
6462
$result = [
6563
'value' => ($found ? $found->value : 0),
6664
'label' => $startDate->toDateString(),
67-
'percent' => ($found ? round($found->value / $sumValues * 100, 2) : 0),
6865
];
6966

7067
$startDate->addDay();

src/Metrics/TimeCollection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function toChart(string $name, \Closure $closure = null): array
4040
'name' => $name,
4141
'labels' => $this->pluck('label')->map($closure)->toArray(),
4242
'values' => $this->pluck('value')->toArray(),
43-
'percent' => $this->pluck('percent')->toArray(),
4443
];
4544
}
4645

src/Platform/Dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Dashboard
2121
/**
2222
* ORCHID Version.
2323
*/
24-
public const VERSION = '14.13.0';
24+
public const VERSION = '14.14.0';
2525

2626
/**
2727
* @deprecated

tests/Unit/MetricsTest.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function testPeriod(): void
7878
'name' => 'Users',
7979
'labels' => $period->pluck('label')->toArray(),
8080
'values' => $period->pluck('value')->toArray(),
81-
'percent' => $period->pluck('percent')->toArray(),
8281
], $period->toChart('Users'));
8382
}
8483

@@ -109,7 +108,6 @@ public function testMaxValuesPeriod(): void
109108
'name' => 'Users',
110109
'labels' => $period->pluck('label')->toArray(),
111110
'values' => $period->pluck('value')->toArray(),
112-
'percent' => $period->pluck('percent')->toArray(),
113111
], $period->toChart('Users'));
114112
}
115113

@@ -140,7 +138,6 @@ public function testMinValuesPeriod(): void
140138
'name' => 'Users',
141139
'labels' => $period->pluck('label')->toArray(),
142140
'values' => $period->pluck('value')->toArray(),
143-
'percent' => $period->pluck('percent')->toArray(),
144141
], $period->toChart('Users'));
145142
}
146143

@@ -170,7 +167,6 @@ public function testSumPeriod(): void
170167
'name' => 'Users',
171168
'labels' => $period->pluck('label')->toArray(),
172169
'values' => $period->pluck('value')->toArray(),
173-
'percent' => $period->pluck('percent')->toArray(),
174170
], $period->toChart('Users'));
175171
}
176172

@@ -200,7 +196,6 @@ public function testAvgPeriod(): void
200196
'name' => 'Users',
201197
'labels' => $period->pluck('label')->toArray(),
202198
'values' => $period->pluck('value')->toArray(),
203-
'percent' => $period->pluck('percent')->toArray(),
204199
], $period->toChart('Users'));
205200
}
206201

@@ -265,50 +260,6 @@ public function testPeriodWithoutZero(): void
265260
'name' => 'Users',
266261
'labels' => $period->pluck('label')->toArray(),
267262
'values' => $period->pluck('value')->toArray(),
268-
'percent' => $period->pluck('percent')->toArray(),
269263
], $period->toChart('Users'));
270264
}
271-
272-
public function testPercentValues(): void
273-
{
274-
$current = Carbon::now();
275-
$start = (clone $current)->subDays(2);
276-
$end = (clone $current)->subDay();
277-
278-
User::factory()->count(1)->create([
279-
'created_at' => $start,
280-
]);
281-
282-
User::factory()->count(2)->create([
283-
'created_at' => $end,
284-
]);
285-
286-
$period = User::countByDays($start);
287-
288-
$expected = [
289-
[
290-
'value' => 1,
291-
'label' => $start->toDateString(),
292-
'percent' => 33.33,
293-
],
294-
[
295-
'value' => 2,
296-
'label' => $end->toDateString(),
297-
'percent' => 66.67,
298-
],
299-
[
300-
'value' => 0,
301-
'label' => $end->copy()->addDay()->toDateString(),
302-
'percent' => 0,
303-
],
304-
];
305-
306-
$actual = $period->all();
307-
308-
$this->assertEquals($expected, $actual);
309-
310-
$user = $period->toChart('Users');
311-
312-
$this->assertSame([33.33, 66.67, 0], $user['percent']);
313-
}
314265
}

0 commit comments

Comments
 (0)