Remove Amazon filament price tracking
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 2m41s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 2m41s
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\EtsyConnection;
|
||||
use App\Models\Filament;
|
||||
use App\Services\Bambuddy;
|
||||
use App\Services\DryerClient;
|
||||
use App\Services\Etsy;
|
||||
@@ -18,16 +17,6 @@ class DashboardController extends Controller
|
||||
public function __invoke(Request $request, Etsy $etsy, Bambuddy $bambuddy, Parcel2Go $parcel2Go, DryerClient $dryer): View
|
||||
{
|
||||
$isAdmin = $request->user()->role === 'admin';
|
||||
$filamentCount = Filament::count();
|
||||
$recentFilaments = Filament::with(['prices' => fn ($query) => $query->orderByDesc('recordedAt')->limit(1)])
|
||||
->orderByDesc('id')->limit(4)->get();
|
||||
$materials = Filament::query()->select('material')->selectRaw('COUNT(*) as total')
|
||||
->groupBy('material')->orderByDesc('total')->get()
|
||||
->map(fn (Filament $filament): array => [
|
||||
'label' => $filament->material ?: 'Unspecified',
|
||||
'count' => (int) $filament->total,
|
||||
])->all();
|
||||
|
||||
$etsyStatus = $isAdmin ? 'Not connected' : null;
|
||||
$etsyConnected = false;
|
||||
$receipts = [];
|
||||
@@ -75,11 +64,25 @@ class DashboardController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$printingCount = collect($printers)->filter(fn (array $printer): bool => in_array(
|
||||
strtoupper((string) ($printer['live']['state'] ?? $printer['status'] ?? '')),
|
||||
['RUNNING', 'PRINTING'],
|
||||
true,
|
||||
))->count();
|
||||
$printerStates = collect($printers)->countBy(function (array $printer): string {
|
||||
$live = $printer['live'] ?? [];
|
||||
$state = strtoupper((string) ($live['state'] ?? $printer['status'] ?? ''));
|
||||
|
||||
if ($live === []) {
|
||||
return 'Unavailable';
|
||||
}
|
||||
if (($live['connected'] ?? false) === false) {
|
||||
return 'Offline';
|
||||
}
|
||||
if (in_array($state, ['RUNNING', 'PRINTING'], true)) {
|
||||
return 'Printing';
|
||||
}
|
||||
if (in_array($state, ['IDLE', 'READY', 'FINISH'], true)) {
|
||||
return 'Idle';
|
||||
}
|
||||
|
||||
return 'Other';
|
||||
});
|
||||
|
||||
$dryerState = 'Not configured';
|
||||
if (filled(config('services.dryer.api_key'))) {
|
||||
@@ -99,9 +102,6 @@ class DashboardController extends Controller
|
||||
|
||||
return view('dashboard', [
|
||||
'isAdmin' => $isAdmin,
|
||||
'filamentCount' => $filamentCount,
|
||||
'recentFilaments' => $recentFilaments,
|
||||
'materials' => $materials,
|
||||
'receipts' => array_slice($receipts, 0, 5),
|
||||
'awaitingDispatch' => count($receipts),
|
||||
'listingCount' => $listingCount,
|
||||
@@ -111,7 +111,11 @@ class DashboardController extends Controller
|
||||
'shippingStatus' => $shippingStatus,
|
||||
'printers' => $printers,
|
||||
'printerStatus' => $printerStatus,
|
||||
'printingCount' => $printingCount,
|
||||
'printingCount' => $printerStates->get('Printing', 0),
|
||||
'printerChart' => $printerStates->map(fn (int $count, string $state): array => [
|
||||
'label' => $state,
|
||||
'count' => $count,
|
||||
])->values()->all(),
|
||||
'dryerState' => $dryerState,
|
||||
'orderChart' => [
|
||||
'labels' => $days->map(fn (Carbon $day): string => $day->format('d M'))->all(),
|
||||
|
||||
Reference in New Issue
Block a user