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

add fav count to !stats

parent 0cd7ac5b
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -14,6 +14,7 @@ has 'date' => (is => 'ro', isa => 'Str'); ...@@ -14,6 +14,7 @@ has 'date' => (is => 'ro', isa => 'Str');
has 'count' => (is => 'ro', isa => 'Int'); has 'count' => (is => 'ro', isa => 'Int');
has 'senders' => (is => 'ro', isa => 'HashRef[Str]'); has 'senders' => (is => 'ro', isa => 'HashRef[Str]');
has 'channels' => (is => 'ro', isa => 'HashRef[Str]'); has 'channels' => (is => 'ro', isa => 'HashRef[Str]');
has 'fav' => (is => 'ro', isa => 'Int');
around 'BUILDARGS' => sub { around 'BUILDARGS' => sub {
...@@ -49,6 +50,17 @@ around 'BUILDARGS' => sub { ...@@ -49,6 +50,17 @@ around 'BUILDARGS' => sub {
$count++; $count++;
} }
my $fav;
$sth = $dbh->prepare('
select count(*)
from playbot_fav
where id = ?
');
$sth->execute($id);
while (my $row = $sth->fetch) {
$fav++;
}
$dbh->commit; $dbh->commit;
return $class->$orig( return $class->$orig(
...@@ -57,7 +69,8 @@ around 'BUILDARGS' => sub { ...@@ -57,7 +69,8 @@ around 'BUILDARGS' => sub {
chan => $chan, chan => $chan,
date => $date, date => $date,
senders => $senders, senders => $senders,
channels => $channels channels => $channels,
fav => $fav,
); );
}; };
......
...@@ -55,6 +55,7 @@ sub stats { ...@@ -55,6 +55,7 @@ sub stats {
my $line1; my $line1;
my $line2; my $line2;
my $line3; my $line3;
my $line4;
$line1 .= 'Posté la 1re fois par '.$stats->sender; $line1 .= 'Posté la 1re fois par '.$stats->sender;
$line1 .= ' le '.$stats->date; $line1 .= ' le '.$stats->date;
...@@ -84,7 +85,13 @@ sub stats { ...@@ -84,7 +85,13 @@ sub stats {
} }
} }
return ($line1, $line2, $line3); if ($stats->fav) {
$line4 = "Sauvegardé dans ses favoris par ";
$line4 .= $stats->fav.' personne';
$line4 .= 's' if ($stats->fav > 1);
}
return ($line1, $line2, $line3, $line4);
} }
1; 1;
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