Skip to content

Commit

Permalink
(#1080) Add total_archives to /api/info
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Sep 29, 2024
1 parent 95e2f91 commit 4fb76dd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/LANraragi/Controller/Api/Other.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ use Redis;
use LANraragi::Model::Stats;
use LANraragi::Model::Opds;
use LANraragi::Utils::TempFolder qw(get_tempsize clean_temp_full);
use LANraragi::Utils::Generic qw(render_api_response);
use LANraragi::Utils::Plugins qw(get_plugin get_plugins get_plugin_parameters use_plugin);
use LANraragi::Utils::Generic qw(render_api_response);
use LANraragi::Utils::Plugins qw(get_plugin get_plugins get_plugin_parameters use_plugin);

sub serve_serverinfo {
my $self = shift;

my $redis = $self->LRR_CONF->get_redis_config;
my $last_clear = $redis->hget( "LRR_SEARCHCACHE", "created" ) || time;
my $arc_stat = LANraragi::Model::Stats::get_archive_count;
my $page_stat = LANraragi::Model::Stats::get_page_stat;
$redis->quit();

# A simple endpoint that forwards some info from LRR_CONF.
# TODO: This API renders every parameter as strings for compat, but at some point we could change it to actual JSON types:
# eg enable_pass ? \1 : \0, get_pagesize + 0, removing the quotes around numbers that force them to strings
$self->render(
json => {
name => $self->LRR_CONF->get_htmltitle,
Expand All @@ -32,7 +35,8 @@ sub serve_serverinfo {
archives_per_page => $self->LRR_CONF->get_pagesize,
server_resizes_images => $self->LRR_CONF->enable_resize,
server_tracks_progress => $self->LRR_CONF->enable_localprogress ? "0" : "1",
total_pages_read => $page_stat,
total_pages_read => "$page_stat",
total_archives => "$arc_stat",
cache_last_cleared => "$last_clear"
}
);
Expand Down Expand Up @@ -130,7 +134,7 @@ sub download_url {

# Uses a plugin, with the standard global arguments and a provided oneshot argument.
sub use_plugin_sync {
my ($self) = shift;
my ($self) = shift;
my $id = $self->req->param('id') || 0;
my $plugname = $self->req->param('plugin');
my $input = $self->req->param('arg');
Expand All @@ -152,7 +156,7 @@ sub use_plugin_sync {

# Queues a plugin execution into Minion.
sub use_plugin_async {
my ($self) = shift;
my ($self) = shift;
my $id = $self->req->param('id') || 0;
my $priority = $self->req->param('priority') || 0;
my $plugname = $self->req->param('plugin');
Expand Down

0 comments on commit 4fb76dd

Please sign in to comment.