Major overhaul to the Notes/Issues. Minor tweaks to the UI. Added Profile photos
This commit is contained in:
@@ -6,7 +6,7 @@ from equipment.models import NoteCreate, NoteUpdate, NoteInDB
|
||||
|
||||
COLLECTION = "equipment_notes"
|
||||
|
||||
VALID_CATEGORIES = {"general", "maintenance", "installation", "issue", "other"}
|
||||
VALID_CATEGORIES = {"general", "maintenance", "installation", "issue", "action_item", "other"}
|
||||
|
||||
|
||||
def _convert_firestore_value(val):
|
||||
@@ -81,7 +81,10 @@ def list_notes(
|
||||
if user_id:
|
||||
query = query.where("user_id", "==", user_id)
|
||||
|
||||
query = query.order_by("created_at", direction="DESCENDING")
|
||||
# Only use order_by when no field filters are applied (avoids composite index requirement)
|
||||
has_field_filters = bool(category or device_id or user_id)
|
||||
if not has_field_filters:
|
||||
query = query.order_by("created_at", direction="DESCENDING")
|
||||
|
||||
docs = query.stream()
|
||||
results = []
|
||||
@@ -98,6 +101,10 @@ def list_notes(
|
||||
|
||||
results.append(note)
|
||||
|
||||
# Sort client-side when we couldn't use order_by
|
||||
if has_field_filters:
|
||||
results.sort(key=lambda n: n.created_at or "", reverse=True)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user