Skip to content

Commit 4fb76dd

Browse files
committed
(#1080) Add total_archives to /api/info
1 parent 95e2f91 commit 4fb76dd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/LANraragi/Controller/Api/Other.pm

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ use Redis;
77
use LANraragi::Model::Stats;
88
use LANraragi::Model::Opds;
99
use LANraragi::Utils::TempFolder qw(get_tempsize clean_temp_full);
10-
use LANraragi::Utils::Generic qw(render_api_response);
11-
use LANraragi::Utils::Plugins qw(get_plugin get_plugins get_plugin_parameters use_plugin);
10+
use LANraragi::Utils::Generic qw(render_api_response);
11+
use LANraragi::Utils::Plugins qw(get_plugin get_plugins get_plugin_parameters use_plugin);
1212

1313
sub serve_serverinfo {
1414
my $self = shift;
1515

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

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

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

153157
# Queues a plugin execution into Minion.
154158
sub use_plugin_async {
155-
my ($self) = shift;
159+
my ($self) = shift;
156160
my $id = $self->req->param('id') || 0;
157161
my $priority = $self->req->param('priority') || 0;
158162
my $plugname = $self->req->param('plugin');

0 commit comments

Comments
 (0)