Skip to content

Commit

Permalink
return single object when fetching cap/core by serial
Browse files Browse the repository at this point in the history
fixed issue r-spacex#36
  • Loading branch information
waterskier2007 committed Jul 27, 2017
1 parent 0227bf1 commit 6bdcb00
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app.rb
Expand Up @@ -256,12 +256,7 @@ class SpacexAPI < Sinatra::Base
cap = params['cap']
collection = client[:launch]
hash = collection.find({cap_serial: "#{cap}"}, projection: {_id: 0}).sort({capsule_serial: 1})
array = hash.to_a
if array.empty?
JSON.pretty_generate(error)
else
JSON.pretty_generate(array)
end
JSON.pretty_generate(hash.to_a[0])
end

# Get all Dragon core information
Expand All @@ -283,12 +278,7 @@ class SpacexAPI < Sinatra::Base
core = params['core']
collection = client[:core]
hash = collection.find({core_serial: "#{core}"}, projection: {_id: 0}).sort({core_serial: 1})
array = hash.to_a
if array.empty?
JSON.pretty_generate(error)
else
JSON.pretty_generate(array)
end
JSON.pretty_generate(hash.to_a[0])
end
end
end

0 comments on commit 6bdcb00

Please sign in to comment.