Display role vocabulary, migration commit fix, stale enforcement reports

This commit is contained in:
2026-08-13 09:30:40 -04:00
parent d327ea1a5c
commit 5dcc7e30af
16 changed files with 490 additions and 46 deletions

View File

@@ -16,7 +16,7 @@ from datetime import datetime, timezone
from flask import current_app
from sqlalchemy import func
from shopdb.api import db, Application
from shopdb.api import db, Application, normalize_display_role
from .models import (
ManifestScope, ManifestPublishedVersion, ManifestEnforcementReport,
@@ -49,6 +49,25 @@ class LibVersionTooOldError(Exception):
'if you are certain those PCs must not receive this scope.')
def _canonical_subtype(value):
"""Store a reported subtype under core's role vocabulary where it names one.
A display reports the literal contents of C:\\Enrollment\\display-type.txt,
hand-edited on the machine, so casing drifts freely. Normalising on the way
in means the fleet table reads one vocabulary rather than whatever each
kiosk happened to be typed as.
A value that names NO known role is kept VERBATIM, not dropped: an unknown
subtype is a kiosk with a typo or a role nobody told the server about, and
both are things you want to see in the table rather than have silently
blanked. Non-display scopes report no subtype at all and land as None.
"""
text = (value or '').strip()
if not text:
return None
return normalize_display_role(text) or text
def _utcnow():
return datetime.now(timezone.utc).replace(tzinfo=None)
@@ -263,7 +282,7 @@ def record_enforcement_report(payload):
phase=phase,
appliedversion=payload.get('appliedversion'),
enforcerversion=payload.get('enforcerversion'),
subtype=(payload.get('subtype') or None),
subtype=_canonical_subtype(payload.get('subtype')),
installedcount=installed,
skippedcount=int(counts.get('skipped', 0)),
failedcount=failed,