backend: rewrite tag#show tag retrieval
This commit is contained in:
parent
724bfbc82a
commit
b4e970bd3a
@ -52,15 +52,9 @@ sub show ($self)
|
|||||||
) if $v->has_error;
|
) if $v->has_error;
|
||||||
|
|
||||||
my $tag_id_or_name = $self->stash("tag_id_or_name");
|
my $tag_id_or_name = $self->stash("tag_id_or_name");
|
||||||
|
my $search_key = $tag_id_or_name =~ /^[1-9][0-9]*$/ ? "tag_id" : "name";
|
||||||
my @search;
|
my $tag = $self->schema->resultset("Tag")
|
||||||
if ($tag_id_or_name =~ /^[1-9][0-9]*$/) {
|
->single({ $search_key => $tag_id_or_name });
|
||||||
push @search, { tag_id => $tag_id_or_name };
|
|
||||||
} else {
|
|
||||||
push @search, { name => $tag_id_or_name };
|
|
||||||
}
|
|
||||||
|
|
||||||
my $tag = $self->schema->resultset("Tag")->single([ @search ]);
|
|
||||||
|
|
||||||
return $self->render(
|
return $self->render(
|
||||||
json => {error => "Tag not found"},
|
json => {error => "Tag not found"},
|
||||||
|
Loading…
Reference in New Issue
Block a user