home · contact · privacy
Treat tag filter input fields as OR of comma-delimited terms.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 23:38:43 +0000 (00:38 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 23:38:43 +0000 (00:38 +0100)
src/ytplom/misc.py

index 90c5e3e4e066e4f46bad7c456a18fa875fbf37c0..e3d3728587980f79d2eee10ab5b647e396a9aaeb 100644 (file)
@@ -305,11 +305,18 @@ class VideoFile(DbData):
                      show_absent: bool = False
                      ) -> list[Self]:
         """Return cls.get_all matching provided filter criteria."""
-        return [f for f in cls.get_all(conn)
+        filtered_before_tags = [
+                f for f in cls.get_all(conn)
                 if str(filter_path).lower() in str(f.rel_path).lower()
-                and ([t for t in f.tags if str(filter_tags).lower() in t]
-                     or not filter_tags)
                 and (show_absent or f.present)]
+        if filter_tags:
+            tags_or = filter_tags.split(',')
+            filtered_after_tags = set()
+            for f in filtered_before_tags:
+                for t in [t for t in tags_or if t in f.tags]:
+                    filtered_after_tags.add(f)
+            return list(filtered_after_tags)
+        return filtered_before_tags
 
     def unused_tags(self, conn: BaseDbConn) -> set[Tag]:
         """Return tags used among other VideoFiles, not in self."""