"(series_id, date, value) " .
"VALUES (?, ?, ?)");
+ my $deletesth = $dbh->prepare("DELETE FROM series_data
+ WHERE series_id = ? AND date = ?");
+
# Fields in the data file (matches the current collectstats.pl)
my @statuses =
qw(NEW ASSIGNED REOPENED UNCONFIRMED RESOLVED VERIFIED CLOSED);
# Insert values into series_data: series_id, date, value
my %fielddata = %{$data{$field}};
foreach my $date (keys %fielddata) {
+ # We need to delete in case the text file had duplicate entries
+ # in it.
+ $deletesth->execute($seriesids{$field},
+ $dbh->quote($date));
+
# We prepared this above
$seriesdatasth->execute($seriesids{$field},
$dbh->quote($date),
"(series_id, date, value) " .
"VALUES (?, " . $dbh->quote($today) . ", ?)");
+ # We delete from the table beforehand, to avoid SQL errors if people run
+ # collectstats.pl twice on the same day.
+ my $deletesth = $dbh->prepare("DELETE FROM series_data
+ WHERE series_id = ? AND date = " .
+ $dbh->quote($today));
+
foreach my $series_id (keys %$serieses) {
# We set up the user for Search.pm's permission checking - each series
# runs with the permissions of its creator.
my $count = scalar(@$data) || 0;
+ $deletesth->execute($series_id);
$sth->execute($series_id, $count);
}
}