hotpocket.sh: change applyTopicsToTags merging algorithm
This commit is contained in:
parent
0e4e9504a1
commit
07a96b883a
15
hotpocket.sh
15
hotpocket.sh
@ -232,7 +232,17 @@ oneOfTagsAsArray () {
|
|||||||
|
|
||||||
applyTopicsToTags () {
|
applyTopicsToTags () {
|
||||||
# applyTopicsToTags:
|
# applyTopicsToTags:
|
||||||
jq --argjson aliases "$TOPICS" '[foreach ($aliases | to_entries[]) as $alias (.; if any($alias.value[] == .) then . + [$alias.key] else . end)] | last' --< /dev/stdin
|
# TODO: While this uses action's tags to match against instead of the rules, it doesn't report the
|
||||||
|
# alias which is resulting in the match. Needs more looking into
|
||||||
|
# jq --argjson aliases "$TOPICS" '[foreach ($aliases | to_entries[]) as $alias (.; if any($alias.value[] == .) then . + [$alias.key] else . end)] | last' --< /dev/stdin
|
||||||
|
jq --argjson topics "$TOPICS" \
|
||||||
|
'[foreach ($topics | to_entries | reverse[]) as $topic (.;
|
||||||
|
if index($topic.key) then
|
||||||
|
. + $topic.value
|
||||||
|
else
|
||||||
|
.
|
||||||
|
end
|
||||||
|
)] | last' < /dev/stdin
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,8 +366,7 @@ ingestRule () {
|
|||||||
local match
|
local match
|
||||||
local code
|
local code
|
||||||
|
|
||||||
# TODO
|
rule_tags="$(oneOfTagsAsArray <<< "$1")" || return 1
|
||||||
rule_tags="$(oneOfTagsAsArray <<< "$1" | applyTopicsToTags)" || return 1
|
|
||||||
|
|
||||||
for actions_index in $(arrayIndexList "$ACTIONS"); do
|
for actions_index in $(arrayIndexList "$ACTIONS"); do
|
||||||
action="$(jq ".[$((actions_index-1))]" -rc <<< "$ACTIONS")" || return 2
|
action="$(jq ".[$((actions_index-1))]" -rc <<< "$ACTIONS")" || return 2
|
||||||
|
Reference in New Issue
Block a user