mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Add date for quickest/longest answer qstat
This commit is contained in:
parent
afad192b83
commit
ae128442a8
@ -44,8 +44,10 @@ CREATE TABLE IF NOT EXISTS QStats (
|
|||||||
highest_wrong_streak INTEGER DEFAULT 0,
|
highest_wrong_streak INTEGER DEFAULT 0,
|
||||||
hints INTEGER DEFAULT 0,
|
hints INTEGER DEFAULT 0,
|
||||||
quickest_answer_time NUMERIC DEFAULT 0,
|
quickest_answer_time NUMERIC DEFAULT 0,
|
||||||
|
quickest_answer_date NUMERIC DEFAULT 0,
|
||||||
quickest_answer_nick TEXT COLLATE NOCASE DEFAULT NULL,
|
quickest_answer_nick TEXT COLLATE NOCASE DEFAULT NULL,
|
||||||
longest_answer_time NUMERIC DEFAULT 0,
|
longest_answer_time NUMERIC DEFAULT 0,
|
||||||
|
longest_answer_date NUMERIC DEFAULT 0,
|
||||||
longest_answer_nick TEXT COLLATE NOCASE DEFAULT NULL,
|
longest_answer_nick TEXT COLLATE NOCASE DEFAULT NULL,
|
||||||
average_answer_time NUMERIC DEFAULT 0
|
average_answer_time NUMERIC DEFAULT 0
|
||||||
)
|
)
|
||||||
@ -74,6 +76,19 @@ sub end {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub find_question {
|
||||||
|
my ($self, $id) = @_;
|
||||||
|
|
||||||
|
my $exists = eval {
|
||||||
|
my $sth = $self->{dbh}->prepare('SELECT 1 FROM QStats WHERE id = ?');
|
||||||
|
$sth->bind_param(1, $id);
|
||||||
|
$sth->execute();
|
||||||
|
return $sth->fetchrow_hashref();
|
||||||
|
};
|
||||||
|
print STDERR $@ if $@;
|
||||||
|
return $exists;
|
||||||
|
}
|
||||||
|
|
||||||
sub add_question {
|
sub add_question {
|
||||||
my ($self, $id) = @_;
|
my ($self, $id) = @_;
|
||||||
|
|
||||||
|
@ -197,11 +197,13 @@ foreach my $answer (@valid_answers) {
|
|||||||
|
|
||||||
if ($qdata->{quickest_answer_time} == 0 or $elapsed < $qdata->{quickest_answer_time}) {
|
if ($qdata->{quickest_answer_time} == 0 or $elapsed < $qdata->{quickest_answer_time}) {
|
||||||
$qdata->{quickest_answer_time} = $elapsed;
|
$qdata->{quickest_answer_time} = $elapsed;
|
||||||
|
$qdata->{quickest_answer_date} = gettimeofday;
|
||||||
$qdata->{quickest_answer_nick} = $nick;
|
$qdata->{quickest_answer_nick} = $nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($elapsed > $qdata->{longest_answer_time}) {
|
if ($elapsed > $qdata->{longest_answer_time}) {
|
||||||
$qdata->{longest_answer_time} = $elapsed;
|
$qdata->{longest_answer_time} = $elapsed;
|
||||||
|
$qdata->{longest_answer_date} = gettimeofday;
|
||||||
$qdata->{longest_answer_nick} = $nick;
|
$qdata->{longest_answer_nick} = $nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user