Phase 2 UI Adjustments/Edits by bonamin
This commit is contained in:
@@ -8,6 +8,13 @@ COLLECTION = "melodies"
|
||||
def _doc_to_melody(doc) -> MelodyInDB:
|
||||
"""Convert a Firestore document snapshot to a MelodyInDB model."""
|
||||
data = doc.to_dict()
|
||||
# Backward compat: if name/description are plain strings, wrap as dict
|
||||
info = data.get("information", {})
|
||||
if isinstance(info.get("name"), str):
|
||||
info["name"] = {"en": info["name"]} if info["name"] else {}
|
||||
if isinstance(info.get("description"), str):
|
||||
info["description"] = {"en": info["description"]} if info["description"] else {}
|
||||
data["information"] = info
|
||||
return MelodyInDB(id=doc.id, **data)
|
||||
|
||||
|
||||
@@ -41,8 +48,16 @@ def list_melodies(
|
||||
continue
|
||||
if search:
|
||||
search_lower = search.lower()
|
||||
name_match = search_lower in melody.information.name.lower()
|
||||
desc_match = search_lower in melody.information.description.lower()
|
||||
name_match = any(
|
||||
search_lower in v.lower()
|
||||
for v in melody.information.name.values()
|
||||
if isinstance(v, str)
|
||||
)
|
||||
desc_match = any(
|
||||
search_lower in v.lower()
|
||||
for v in melody.information.description.values()
|
||||
if isinstance(v, str)
|
||||
)
|
||||
tag_match = any(search_lower in t.lower() for t in melody.information.customTags)
|
||||
if not (name_match or desc_match or tag_match):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user