mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-06-22 22:19:03 +01:00
filament usage chart now works without day constraint
This commit is contained in:
@@ -24,7 +24,6 @@ _METRICS_API_FIELDS = [
|
|||||||
'external_spool',
|
'external_spool',
|
||||||
]
|
]
|
||||||
_MAX_CHART_POINTS = 3000
|
_MAX_CHART_POINTS = 3000
|
||||||
_FILAMENT_TIMELINE_MAX_STEP = 10 # disable filament timeline for ranges > ~10 days
|
|
||||||
|
|
||||||
|
|
||||||
class PrinterDashboardView(LoginRequiredMixin, TemplateView):
|
class PrinterDashboardView(LoginRequiredMixin, TemplateView):
|
||||||
@@ -297,9 +296,8 @@ class PrinterDataAPIView(LoginRequiredMixin, View):
|
|||||||
total_points = len(metrics_list)
|
total_points = len(metrics_list)
|
||||||
|
|
||||||
# Stage C: targeted snapshot fetch (only sampled IDs)
|
# Stage C: targeted snapshot fetch (only sampled IDs)
|
||||||
include_filament = (step <= _FILAMENT_TIMELINE_MAX_STEP)
|
|
||||||
snapshots_by_metric: dict = {}
|
snapshots_by_metric: dict = {}
|
||||||
if include_filament and metrics_list:
|
if metrics_list:
|
||||||
sampled_ids = [m.id for m in metrics_list]
|
sampled_ids = [m.id for m in metrics_list]
|
||||||
for snap in FilamentSnapshot.objects.filter(printer_metric_id__in=sampled_ids):
|
for snap in FilamentSnapshot.objects.filter(printer_metric_id__in=sampled_ids):
|
||||||
snapshots_by_metric.setdefault(snap.printer_metric_id, []).append(snap)
|
snapshots_by_metric.setdefault(snap.printer_metric_id, []).append(snap)
|
||||||
@@ -374,8 +372,7 @@ class PrinterDataAPIView(LoginRequiredMixin, View):
|
|||||||
current_job = None
|
current_job = None
|
||||||
last_state = gs
|
last_state = gs
|
||||||
|
|
||||||
# Filament timeline (inline, only when include_filament)
|
# Filament timeline (inline)
|
||||||
if include_filament:
|
|
||||||
for snap in snapshots_by_metric.get(m.id, []):
|
for snap in snapshots_by_metric.get(m.id, []):
|
||||||
tray_id = snap.tray_id
|
tray_id = snap.tray_id
|
||||||
fil_type = snap.type or 'Unknown'
|
fil_type = snap.type or 'Unknown'
|
||||||
|
|||||||
Reference in New Issue
Block a user