CUB-8: Create background service for Moonraker mapping #29

Merged
Otto merged 1 commits from agent/dex/CUB-8-background-service-moonraker into dev 2026-04-27 20:42:51 -04:00
Owner

What

Creates a background service that periodically polls Moonraker printers and maps printer status + print job history into the Extrudex database.

Changes

  • MoonrakerPrinterSyncOptions — config section MoonrakerPrinterSync (polling interval, timeout, enabled, history batch size)
  • IMoonrakerPrinterSyncService — interface for the sync service
  • MoonrakerPrinterSyncService — syncs printer status via GetPrinterInfoAsync + GetPrintStatsAsync, maps print history to PrintJob and FilamentUsage entities with derived grams calculation
  • MoonrakerPrinterSyncJobBackgroundService host that runs the sync on a configurable interval
  • Program.cs — DI registration for options, service, and hosted service
  • appsettings.json — default MoonrakerPrinterSync config section

Key design decisions

  • Printer status mapped from print_stats.state (authoritative) with fallback to printer_info.state
  • Moonraker JobId stored as moonraker:<id> in GcodeFilePath for dedup
  • Only completed/cancelled/errored jobs are mapped (in_progress skipped until finished)
  • Grams derived using spool filament diameter + material density from MaterialBase
  • Default spool resolved from first active AMS slot

Linear

Closes CUB-8

## What Creates a background service that periodically polls Moonraker printers and maps printer status + print job history into the Extrudex database. ## Changes - **MoonrakerPrinterSyncOptions** — config section `MoonrakerPrinterSync` (polling interval, timeout, enabled, history batch size) - **IMoonrakerPrinterSyncService** — interface for the sync service - **MoonrakerPrinterSyncService** — syncs printer status via `GetPrinterInfoAsync` + `GetPrintStatsAsync`, maps print history to `PrintJob` and `FilamentUsage` entities with derived grams calculation - **MoonrakerPrinterSyncJob** — `BackgroundService` host that runs the sync on a configurable interval - **Program.cs** — DI registration for options, service, and hosted service - **appsettings.json** — default MoonrakerPrinterSync config section ## Key design decisions - Printer status mapped from `print_stats.state` (authoritative) with fallback to `printer_info.state` - Moonraker JobId stored as `moonraker:<id>` in `GcodeFilePath` for dedup - Only completed/cancelled/errored jobs are mapped (in_progress skipped until finished) - Grams derived using spool filament diameter + material density from `MaterialBase` - Default spool resolved from first active AMS slot ## Linear Closes CUB-8
Dex added 1 commit 2026-04-27 20:40:34 -04:00
feat(CUB-8): Create background service for Moonraker mapping
All checks were successful
Dev Build / build-test (pull_request) Successful in 2m7s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Has been skipped
8b2a29881d
Otto approved these changes 2026-04-27 20:42:50 -04:00
Otto left a comment
Owner

APPROVED — base=dev, author=Dex, 6 files (+473), dotnet build PASS 0 errors, Closes CUB-8 present. Great architecture: options pattern, IHostedService, configurable polling, clean DTO mapping.

APPROVED — base=dev, author=Dex, 6 files (+473), dotnet build PASS 0 errors, Closes CUB-8 present. Great architecture: options pattern, IHostedService, configurable polling, clean DTO mapping.
Otto merged commit b86dda97a3 into dev 2026-04-27 20:42:51 -04:00
Otto deleted branch agent/dex/CUB-8-background-service-moonraker 2026-04-27 20:42:51 -04:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CubeCraft-Creations/Extrudex#29