Commit 1c2cee53 authored by Luc Didry's avatar Luc Didry

Add instance statistics at /fullstats

parent 1fbe93a7
......@@ -319,6 +319,11 @@ sub startup {
shift->render(template => 'about');
})->name('about');
# Get instance stats
$r->get('/fullstats')
->to('Misc#fullstats')
->name('fullstats');
# Get a file
$r->get('/r/:short')->
to('Files#r')->
......
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
package Lufi::Controller::Misc;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::File;
use LufiDB;
use Lufi::File;
use Lufi::Slice;
sub fullstats {
my $c = shift;
my $files = LufiDB::Files->count('WHERE created_at IS NOT null AND deleted = 0');
my $deleted = LufiDB::Files->count('WHERE created_at IS NOT null AND deleted = 1');
my $empty = LufiDB::Files->count('WHERE created_at IS null');
return $c->render(
json => {
files => $files,
deleted => $deleted,
empty => $empty,
timestamp => time,
}
);
}
1;
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