selectByComponents

This commit is contained in:
2021-07-10 16:16:13 -06:00
parent 094e512009
commit b05da63720
3 changed files with 10 additions and 2 deletions

View File

@@ -181,4 +181,7 @@
entries) // TODO this includes entries that didn't have the tag in the changeset
(defcommand selectByTags [tagsBoolExp (Text null)]
(selectEntries (filter archive.entries ->e (tagsMatch archive e tagsBoolExp)))))
(selectEntries (filter archive.entries ->e (tagsMatch archive e tagsBoolExp))))
(defcommand selectByComponents [componentsBoolExp (Text null)]
(selectEntries (filter archive.entries ->e (componentsMatch e componentsBoolExp)))))

View File

@@ -70,4 +70,7 @@
(collect (t.keys))))
(defun tagsMatch [archive e tagsBoolExp]
(BoolExpInterp.eval tagsBoolExp (tagList archive e)))
(BoolExpInterp.eval tagsBoolExp (tagList archive e)))
(defun componentsMatch [:nat.Entry e componentsBoolExp]
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))

View File

@@ -21,6 +21,8 @@
(assert (hasComponent song1 Tags))
(assert (hasComponent song2 Tags))
(assert (componentsMatch song1 "(and Name Author)"))
(assert (componentsMatch song2 "(and Name Author)"))
(assert (tagsMatch archive song1 "(and song western)"))
(assert !(tagsMatch archive song1 "(and song religious)"))
(assert (tagsMatch archive song2 "(and song religious)"))