diff --git a/PlayBot/commands/get.pm b/PlayBot/commands/get.pm index babc641be3a31dbfb82e8f6e9999ffacfa23fa96..384d5811827da0cce0755e2c7bad22947e4042d1 100644 --- a/PlayBot/commands/get.pm +++ b/PlayBot/commands/get.pm @@ -30,7 +30,8 @@ sub exec { and $rows > 10 and not $query->force) { - $irc->yield(privmsg => $chan => "trop de résultats ($rows), utiliser -f pour forcer la recherche"); + my $search_name = $db_query->make_view($query); + $irc->yield(privmsg => $chan => "trop de résultats ($rows), utilise -f pour forcer la recherche ou va voir ici : http://nightiies.iiens.net/links/search/$search_name"); return; } diff --git a/PlayBot/utils/db/get.pm b/PlayBot/utils/db/get.pm index 1d00e884221a3eb192c4bb9b68c7806b55b649e0..6fd1a6847bd2661293c20be37e7d8fdd787db21a 100644 --- a/PlayBot/utils/db/get.pm +++ b/PlayBot/utils/db/get.pm @@ -85,6 +85,28 @@ sub get_rows { return $rows; } +sub make_view { + my ($self, $query) = @_; + + my $dbh = PlayBot::utils::db::get_new_session(); + $dbh->{AutoCommit} = 0; + + my ($request, @args) = $self->_prepare_request($query); + my $view_name = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..32; + my $sth = $dbh->prepare('create view '.$view_name.' AS '.$request); + $sth->execute(@args); + + $dbh->do('create event clear'.$view_name.' + on schedule at current_timestamp + interval 1 hour + do + drop view '.$view_name); + + $dbh->commit; + $dbh->disconnect; + + return $view_name; +} + sub _get_next { my ($self, $query) = @_; my $chan = $query->chan;