Commit 507d0361 authored by Paul Wise's avatar Paul Wise

popcon-data: look up useful dates when the date range is unspecified

This is needed so that links to the raw data can be added.

Redirect to a URL including the date range so that
the vistor can then edit the date range afterwards.
parent fc219c03
......@@ -14,6 +14,7 @@
use warnings;
use strict;
use URI;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use DBD::Pg;
......@@ -39,6 +40,15 @@ unless (@packages) {
exit;
}
if (!$from_date || !$to_date) {
$from_date = $dbh->selectrow_array('SELECT min(p.day) FROM popcon_package pp JOIN popcon p ON (pp.id = p.package_id) JOIN popcon_day pd ON (pd.day = p.day) WHERE package = ANY(?) AND in_debian AND (p.vote > 0 OR p.old > 0 OR p.recent > 0 or p.no_files > 0)', undef, \@packages) if !$from_date;
$to_date = $dbh->selectrow_array('SELECT max(p.day) FROM popcon_package pp JOIN popcon p ON (pp.id = p.package_id) JOIN popcon_day pd ON (pd.day = p.day) WHERE package = ANY(?) AND in_debian AND (p.vote > 0 OR p.old > 0 OR p.recent > 0 or p.no_files > 0)', undef, \@packages) if !$to_date;
my $uri = URI->new("https://qa.debian.org/cgi-bin/popcon-data");
$uri->query_form( [ packages => "@packages", from_date => $from_date, to_date => $to_date ], ';' );
print $cgi->redirect($uri);
exit;
}
my %data = ();
foreach my $package (@packages) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment