api, backend: improve references uses

This commit is contained in:
Lucas 2023-03-15 22:41:45 +00:00
parent 672192441d
commit 37a2806f03
4 changed files with 10 additions and 10 deletions

View File

@ -21,14 +21,14 @@ sub list ($self)
) if $v->has_error;
my $paged_media = $self->schema->resultset("Media")
->search({}, $MEDIA_SEARCH_OPTS)->page($page);
->search(undef, { $MEDIA_SEARCH_OPTS->%* })->page($page);
my @media = map +{
media_id => $_->media_id,
seaweedfs_fid => $_->seaweedfs_fid,
}, $paged_media->all;
return $self->render(json => {
media => \@media,
media => [ @media ],
pager => { $self->pager($paged_media->pager) },
});
};

View File

@ -25,7 +25,7 @@ sub list ($self)
) if $v->has_error;
my $paged_tags = $self->schema->resultset("TagCountView")
->search(undef, $TAGS_COUNT_VIEW_SEARCH_OPTS)->page($page);
->search(undef, { $TAGS_COUNT_VIEW_SEARCH_OPTS->%* })->page($page);
my @tags = map +{
id => $_->tag_id,
name => $_->name,
@ -33,7 +33,7 @@ sub list ($self)
}, $paged_tags->all;
return $self->render(json => {
tags => \@tags,
tags => [ @tags ],
pager => { $self->pager($paged_tags->pager) },
});
};
@ -57,7 +57,7 @@ sub show ($self)
push @search, { name => $tag_id_or_name };
}
my $tag = $self->schema->resultset("Tag")->single(\@search);
my $tag = $self->schema->resultset("Tag")->single([ @search ]);
return $self->render(
json => {error => "Tag not found"},
@ -65,7 +65,7 @@ sub show ($self)
) if !defined($tag);
my $paged_media = $self->schema->resultset("TaggedMediaView")
->search({ tag_id => $tag->tag_id }, $MEDIA_SEARCH_OPTS)
->search({ tag_id => $tag->tag_id }, { $MEDIA_SEARCH_OPTS->%* })
->page($page);
my @media = map +{
media_id => $_->media_id,
@ -75,7 +75,7 @@ sub show ($self)
return $self->render(json => {
id => $tag->tag_id,
name => $tag->name,
media => \@media,
media => [ @media ],
pager => { $self->pager($paged_media->pager) },
});
};

View File

@ -30,7 +30,7 @@ sub index ($self)
return $self->render(
template => "gallery",
media => \@media,
media => [ @media ],
pager => { $self->pager_links($res->json->{pager}) },
);
};

View File

@ -28,7 +28,7 @@ sub list ($self)
return $self->render(
template => "tags",
tags => \@tags,
tags => [ @tags ],
pager => { $self->pager_links($res->json->{pager}) },
);
};
@ -57,7 +57,7 @@ sub show ($self)
return $self->render(
template => "gallery",
media => \@media,
media => [ @media ],
pager => { $self->pager_links($res->json->{pager}) },
);
};