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;
|
||||
|
||||
my $tag_id_or_name = $self->stash("tag_id_or_name");
|
||||
|
||||
my @search;
|
||||
if ($tag_id_or_name =~ /^[1-9][0-9]*$/) {
|
||||
push @search, { tag_id => $tag_id_or_name };
|
||||
} else {
|
||||
push @search, { name => $tag_id_or_name };
|
||||
}
|
||||
|
||||
my $tag = $self->schema->resultset("Tag")->single([ @search ]);
|
||||
my $search_key = $tag_id_or_name =~ /^[1-9][0-9]*$/ ? "tag_id" : "name";
|
||||
my $tag = $self->schema->resultset("Tag")
|
||||
->single({ $search_key => $tag_id_or_name });
|
||||
|
||||
return $self->render(
|
||||
json => {error => "Tag not found"},
|
||||
|
Loading…
Reference in New Issue
Block a user