implement special:untagged

This commit is contained in:
Jann Stute
2024-11-28 23:25:10 +01:00
parent 83e156f69b
commit a784fe68e6
2 changed files with 7 additions and 0 deletions

View File

@@ -37,6 +37,11 @@ class SQLBoolExpressionBuilder(BaseVisitor):
return Entry.suffix.in_(map(lambda x: x.replace(".", ""), extensions))
elif node.type == ConstraintType.FileType:
return Entry.suffix.ilike(node.value)
elif node.type == ConstraintType.Special: # noqa: SIM102 unnecessary once there is a second special constraint
if node.value.lower() == "untagged":
return ~Entry.id.in_(
select(Entry.id).join(Entry.tag_box_fields).join(TagBoxField.tags)
)
# raise exception if Constraint stays unhandled
raise NotImplementedError("This type of constraint is not implemented yet")

View File

@@ -9,6 +9,7 @@ class ConstraintType(Enum): # TODO add remaining ones
MediaType = 2
FileType = 3
Path = 4
Special = 5
@staticmethod
def from_string(text: str) -> "ConstraintType":
@@ -18,6 +19,7 @@ class ConstraintType(Enum): # TODO add remaining ones
"mediatype": ConstraintType.MediaType,
"filetype": ConstraintType.FileType,
"path": ConstraintType.Path,
"special": ConstraintType.Special,
}.get(text.lower(), None)