Last active
October 2, 2018 18:33
-
-
Save honsa/80169e1b222a1ede24b8d5471c650318 to your computer and use it in GitHub Desktop.
Automaticly create rules for new tags in wallabag MySQL database. Search in title and content for keyword and trigger wallabag_tagging_rule insert with this keyword.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN | |
SET @tag = NEW.slug; | |
If length(@tag) >= 3 THEN | |
SET @ruleTitle = CONCAT('title matches " ', @tag,' "'); | |
SET @ruleContent = CONCAT('content matches " ',@tag,' "'); | |
INSERT INTO wallabag_tagging_rule (config_id,rule,tags) VALUES (1,@ruleTitle, @tag); | |
INSERT INTO wallabag_tagging_rule (config_id,rule,tags) VALUES (1,@ruleContent, @tag); | |
END IF; | |
END | |
BEGIN | |
SET @tag = OLD.slug; | |
DELETE FROM wallabag_tagging_rule WHERE tags LIKE @tag; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment