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

!get prints number of results

parent 265c0e55
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -22,6 +22,7 @@ sub exec {
my $content;
my $req;
my $sth;
my $rows;
my @words = ($msg =~ /(?:^| )([a-zA-Z0-9_-]+)/g);
my @words_param;
......@@ -59,8 +60,7 @@ sub exec {
$req .= ' and '.$words_sql if ($words_sql);
$req .= ' group by id
having count(*) >= ?
order by rand()
limit 1';
order by rand()';
$sth = $dbh->prepare($req);
$sth->execute(@tags, @words_param, scalar @tags);
......@@ -75,8 +75,7 @@ sub exec {
$req .= ' and pc.chan = ?
group by p.id
having count(*) >= ?
order by rand()
limit 1';
order by rand()';
$sth = $dbh->prepare($req);
$sth->execute(@tags, @words_param, $chan->[0], scalar @tags);
......@@ -93,7 +92,7 @@ sub exec {
if ($all) {
$req = 'select id, sender, title, url, duration from playbot';
$req .= ' where '.$words_sql if ($words_sql);
$req .= ' order by rand() limit 1';
$req .= ' order by rand()';
$sth = $dbh->prepare($req);
$sth->execute (@words_param);
......@@ -104,8 +103,7 @@ sub exec {
join playbot_chan pc on p.id = pc.content
where pc.chan = ?';
$req .= ' and '.$words_sql if ($words_sql);
$req .= ' order by rand()
limit 1';
$req .= ' order by rand()';
$sth = $dbh->prepare($req);
$sth->execute($chan->[0], @words_param);
......@@ -124,6 +122,9 @@ sub exec {
}
}
# this is specific to the mysql driver
$rows = $sth->rows;
$sth = $dbh->prepare("select tag
from playbot_tags
where id = ?
......@@ -145,7 +146,11 @@ sub exec {
$content_h{'duration'} = $content->[4];
$content_h{'tags'} = \@tags;
$irc->yield(privmsg => $chan => utils::print::print(\%content_h));
my $msg = utils::print::print(\%content_h);
$msg .= ' [' . $rows . ' résultat';
$msg .= 's' if ($rows > 1);
$msg .= ']';
$irc->yield(privmsg => $chan => $msg);
# we save the get like a post
my $sth2 = $dbh->prepare_cached('
......
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