api: rename /random -> /random/media and implement /random/tag
This commit is contained in:
parent
ad6a6cb9c0
commit
88b5354529
@ -114,6 +114,15 @@ get "/tag/:tag_id_or_name" => sub {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get "/random/tag" => sub {
|
||||||
|
my $tag = schema("default")->resultset("Tag")
|
||||||
|
->search({}, { order_by => \"random()", limit => 1 })->single;
|
||||||
|
|
||||||
|
send_error("Tag not found", 404) if !defined($tag);
|
||||||
|
|
||||||
|
forward "/tag/" . $tag->tag_id;
|
||||||
|
};
|
||||||
|
|
||||||
get "/media" => sub {
|
get "/media" => sub {
|
||||||
my $page = query_parameters->get("page") // 1;
|
my $page = query_parameters->get("page") // 1;
|
||||||
send_error("Invalid page number", 400) if !validate_page_number($page);
|
send_error("Invalid page number", 400) if !validate_page_number($page);
|
||||||
@ -155,7 +164,7 @@ get "/download/:media_id" => sub {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
get "/random" => sub {
|
get "/random/media" => sub {
|
||||||
my $media = schema("default")->resultset("Media")
|
my $media = schema("default")->resultset("Media")
|
||||||
->search({}, { order_by => \"random()", limit => 1 })->single;
|
->search({}, { order_by => \"random()", limit => 1 })->single;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user