Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for tanks #1157

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/LANraragi/Model/Tankoubon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sub get_tankoubon ( $tank_id, $fulldata = 0, $page = 0 ) {

%tank = filter_hash_by_keys( \@allowed_keys, %tank );

my $total = $redis->zcard($tank_id) - 1;
my $total = $redis->zcount($tank_id, 1, "+inf");

return ( $total, $#archives + 1, %tank );
}
Expand Down Expand Up @@ -232,8 +232,8 @@ sub update_metadata ( $tank_id, $data ) {
my $redis = LANraragi::Model::Config->get_redis;
my $err = "";
my $name = $data->{"metadata"}->{"name"} || undef;
my $summary = $data->{"metadata"}->{"summary"} || undef;
my $tags = $data->{"metadata"}->{"tags"} || undef;
my $summary = exists $data->{"metadata"}->{"summary"} ? $data->{"metadata"}->{"summary"} : undef;
my $tags = exists $data->{"metadata"}->{"tags"} ? $data->{"metadata"}->{"tags"} : undef;

if ( $redis->exists($tank_id) ) {
if ( defined $name ) {
Expand Down
14 changes: 14 additions & 0 deletions tests/mocks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ sub setup_redis_mock {
}
);

$redis->mock(
'zcount', # $redis->zcard => number of values in list named by key in datamodel
sub {
my $self = shift;
my ( $key, $weight, $value ) = @_;

if ( !exists $datamodel{$key} ) {
$datamodel{$key} = [];
}

return scalar @{ $datamodel{$key} } - 1;
}
);

$redis->mock(
'zcard', # $redis->zcard => number of values in list named by key in datamodel
sub {
Expand Down
4 changes: 3 additions & 1 deletion tests/tankoubon.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ LANraragi::Model::Stats::build_stat_hashes();
my ( $total, $filtered, @rgs );

# Get Tankoubon
my %tankoubon = LANraragi::Model::Tankoubon::get_tankoubon("TANK_1589141306", 0, 0);
my ( $total, $filtered, %tankoubon ) = LANraragi::Model::Tankoubon::get_tankoubon("TANK_1589141306", 0, 0);
is($tankoubon{id}, "TANK_1589141306", 'ID test');
is($tankoubon{name}, "Hello", 'Name test');
is($total, 2, 'Total Test');
is($filtered, 2, 'Count Test');
ok($tankoubon{archives}[0] eq "28697b96f0ac5858be2666ed10ca47742c955555", 'Archives test');

# List Tankoubon
Expand Down
Loading