mirror of
https://gitea.invidious.io/iv-org/instances-api.git
synced 2024-08-15 00:53:15 +00:00
parent
1df56ebcb8
commit
cbc77463be
1 changed files with 2 additions and 5 deletions
|
@ -24,7 +24,7 @@ macro rendered(filename)
|
||||||
render "src/instances/views/#{{{filename}}}.ecr"
|
render "src/instances/views/#{{{filename}}}.ecr"
|
||||||
end
|
end
|
||||||
|
|
||||||
alias Instance = {flag: String?, region: String?, stats: JSON::Any?, type: String, uri: String, monitor: JSON::Any?}
|
alias Instance = NamedTuple(flag: String?, region: String?, stats: JSON::Any?, type: String, uri: String, monitor: JSON::Any?)
|
||||||
|
|
||||||
INSTANCES = {} of String => Instance
|
INSTANCES = {} of String => Instance
|
||||||
|
|
||||||
|
@ -114,10 +114,7 @@ get "/instances.json" do |env|
|
||||||
sort_by = env.params.query["sort_by"]?
|
sort_by = env.params.query["sort_by"]?
|
||||||
sort_by ||= "type,users"
|
sort_by ||= "type,users"
|
||||||
|
|
||||||
instances = sort_instances(INSTANCES, sort_by).map do |instance|
|
instances = sort_instances(INSTANCES, sort_by)
|
||||||
name, value = instance
|
|
||||||
Hash{name => value}
|
|
||||||
end
|
|
||||||
|
|
||||||
if env.params.query["pretty"]?.try &.== "1"
|
if env.params.query["pretty"]?.try &.== "1"
|
||||||
instances.to_pretty_json
|
instances.to_pretty_json
|
||||||
|
|
Loading…
Reference in a new issue