Skip to content
Extraits de code Groupes Projets
Valider b1af6a43 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

searches (!get) with tags *really* work

parent 14f7c413
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -50,35 +50,37 @@ sub exec { ...@@ -50,35 +50,37 @@ sub exec {
$sth->execute($words[0]); $sth->execute($words[0]);
} }
elsif (@tags) { elsif (@tags) {
my $params = join ', ' => ('?') x @tags; my @where;
foreach my $tag (@tags) {
unshift @where, 'p.id in (select pt.id from playbot_tags pt where pt.tag = ?)';
}
my $where = join ' and ' => @where;
if ($all) { if ($all) {
$req = 'select id, sender, title, url, duration $req = 'select id, sender, title, url, duration
from playbot from playbot
natural join playbot_tags where '.$where;
where tag in ('.$params.')';
$req .= ' and '.$words_sql if ($words_sql); $req .= ' and '.$words_sql if ($words_sql);
$req .= ' group by id $req .= ' group by id
having count(*) >= ?
order by rand()'; order by rand()';
$sth = $dbh->prepare($req); $sth = $dbh->prepare($req);
$sth->execute(@tags, @words_param, scalar @tags); $sth->execute(@tags, @words_param);
} }
else { else {
$req = 'select p.id, p.sender, p.title, p.url, duration $req = 'select p.id, p.sender, p.title, p.url, duration
from playbot p from playbot p
natural join playbot_tags pt
join playbot_chan pc on p.id = pc.content join playbot_chan pc on p.id = pc.content
where pt.tag in ('.$params.')'; where '.$where;
$req .= ' and '.$words_sql if ($words_sql); $req .= ' and '.$words_sql if ($words_sql);
$req .= ' and pc.chan = ? $req .= ' and pc.chan = ?
group by p.id group by p.id
having count(*) >= ?
order by rand()'; order by rand()';
$sth = $dbh->prepare($req); $sth = $dbh->prepare($req);
$sth->execute(@tags, @words_param, $chan->[0], scalar @tags); $sth->execute(@tags, @words_param, $chan->[0]);
} }
} }
else { else {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter