Verified Commit ce2d7cf5 authored by Luc Didry's avatar Luc Didry

Add downloads count to stats

parent 530358d6
......@@ -49,14 +49,10 @@ sub fullstats {
my $c = shift;
my $stats = Lufi::DB::File->new(app => $c->app)->get_stats;
$stats->{timestamp} = time;
return $c->render(
json => {
files => $stats->{files},
deleted => $stats->{deleted},
empty => $stats->{empty},
timestamp => time,
}
json => $stats
);
}
......
......@@ -272,11 +272,12 @@ sub get_empty {
sub get_stats {
my $c = shift;
my $files = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 0)->hashes->first->{count};
my $deleted = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 1)->hashes->first->{count};
my $empty = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS null')->hashes->first->{count};
my $files = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 0)->hashes->first->{count};
my $deleted = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 1)->hashes->first->{count};
my $empty = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS null')->hashes->first->{count};
my $downloads = $c->app->dbi->db->query('SELECT SUM(counter) AS sum FROM files')->hashes->first->{sum};
return { files => $files, deleted => $deleted, empty => $empty };
return { files => $files, deleted => $deleted, empty => $empty, downloads => $downloads };
}
=head2 from_short
......
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