Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit e3bfec1

Browse files
Update HomeService to improve user filament statistics handling; adjust welcome page to display average metrics and user count.
1 parent a1a329b commit e3bfec1

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

app/Services/Pages/HomeService.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,22 @@ public function colors(): Collection
3535
return Color::query()
3636
->whereHas('userFilament')
3737
->orderBy('title')
38-
->get(['title', 'hex']);
38+
->get(['id', 'title', 'hex']);
3939
}
4040

41-
public function userFilaments(): Collection
41+
public function userFilaments(int $count = 100): Collection
4242
{
4343
return UserFilament::query()
44+
->select([
45+
'machine_id',
46+
'filament_id',
47+
'color_id',
48+
])
49+
->selectRaw('count(*) as users_count')
50+
->selectRaw('avg(pressure_advance) as pressure_advance')
51+
->selectRaw('avg(filament_flow_ratio) as filament_flow_ratio')
52+
->selectRaw('avg(filament_max_volumetric_speed) as filament_max_volumetric_speed')
53+
->selectRaw('avg(nozzle_temperature) as nozzle_temperature')
4454
->with([
4555
'machine.vendor',
4656
'filament' => ['vendor', 'type'],
@@ -49,7 +59,8 @@ public function userFilaments(): Collection
4959
->orderBy('machine_id')
5060
->orderBy('filament_id')
5161
->orderBy('color_id')
52-
->orderBy('id')
62+
->groupBy(['machine_id', 'filament_id', 'color_id'])
63+
->limit($count)
5364
->get();
5465
}
5566
}

resources/js/pages/welcome.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,25 @@ export default function Welcome({ userFilaments, machines, filamentTypes, colors
6464
Color
6565
</th>
6666
<th className="border border-gray-300 p-3 text-left font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-200">
67-
Pressure Advance
67+
Average Pressure Advance
6868
</th>
6969
<th className="border border-gray-300 p-3 text-left font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-200">
70-
Flow Ratio
70+
Average Flow Ratio
7171
</th>
7272
<th className="border border-gray-300 p-3 text-left font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-200">
73-
Max Volumetric Speed
73+
Average Max Volumetric Speed
7474
</th>
7575
<th className="border border-gray-300 p-3 text-left font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-200">
76-
Nozzle Temperature
76+
Average Nozzle Temperature
77+
</th>
78+
<th className="border border-gray-300 p-3 text-left font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-200">
79+
User Profiles
7780
</th>
7881
</tr>
7982
</thead>
8083
<tbody>
8184
{ userFilaments.map((item) => (
82-
<tr key={ item.id }>
85+
<tr>
8386
<td className="border border-gray-300 p-3 text-left text-gray-900 dark:border-gray-600 dark:text-gray-200">
8487
{ item.machine.vendor.title }&nbsp;
8588
{ item.machine.title }
@@ -103,6 +106,9 @@ export default function Welcome({ userFilaments, machines, filamentTypes, colors
103106
<td className="border border-gray-300 p-3 text-left text-gray-900 dark:border-gray-600 dark:text-gray-200">
104107
{ item.nozzle_temperature }
105108
</td>
109+
<td className="border border-gray-300 p-3 text-left text-gray-900 dark:border-gray-600 dark:text-gray-200">
110+
{ item.users_count }
111+
</td>
106112
</tr>
107113
)) }
108114
</tbody>

resources/js/types/index.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
export interface Auth {
1+
export interface Auth
2+
{
23
user: User;
34
}
45

5-
export interface SharedData {
6+
export interface SharedData
7+
{
68
name: string;
79
quote: { message: string; author: string };
810
auth: Auth;
11+
912
[key: string]: unknown;
1013
}
1114

12-
export interface User {
15+
export interface User
16+
{
1317
id: number;
1418
name: string;
1519
email: string;
1620
avatar?: string;
1721
email_verified_at: string | null;
1822
created_at: string;
1923
updated_at: string;
24+
2025
[key: string]: unknown; // This allows for additional properties...
2126
}

0 commit comments

Comments
 (0)