From 9cc8884b48fd99a3dd2ca1a43e72bd56c51b114f Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Thu, 22 Aug 2013 02:16:13 +0200 Subject: [PATCH] if we insert a duplicate context tag, we don't set context = 0 --- lib/commands/tag.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/commands/tag.pm b/lib/commands/tag.pm index 9f4f552..2331099 100644 --- a/lib/commands/tag.pm +++ b/lib/commands/tag.pm @@ -32,12 +32,19 @@ sub addTag my $stopwords_en = getStopWords('en'); my $stopwords_fr = getStopWords('fr'); - return if ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag}); - - my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) - VALUES (?, ?, ?) - ON DUPLICATE KEY - UPDATE context = 0'); + return if ($context and ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag})); + + my $sth; + + if (!$context) { + $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) + VALUES (?, ?, ?) + ON DUPLICATE KEY + UPDATE context = 0'); + } else { + $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) + VALUES (?, ?, ?)'); + } $log->error("Couldn't prepare querie; aborting") unless (defined $sth); $sth->execute($id, $tag, ($context) ? 1 : 0) -- GitLab