Skip to content

Commit

Permalink
Add earth_date to manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
corincerami committed Aug 16, 2018
1 parent 42265bf commit 3c5563c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -85,6 +85,7 @@ An example entry from `/manifests/Curiosity` might look like:
```
{
sol: 0,
earth_date: "2012-08-06"
total_photos: 3702,
cameras: [
"CHEMCAM",
Expand Down
6 changes: 3 additions & 3 deletions app/models/photo_manifest.rb
Expand Up @@ -10,9 +10,9 @@ def initialize(rover)
end

def to_a
rover.photos.joins(:camera).group(:sol)
.select('sol, count(photos.id) AS cnt, ARRAY_AGG(DISTINCT cameras.name) AS cameras')
.map { |photos| {sol: photos.sol, total_photos: photos.cnt, cameras: photos.cameras} }
rover.photos.joins(:camera).group(:sol, :earth_date)
.select('sol, earth_date, count(photos.id) AS cnt, ARRAY_AGG(DISTINCT cameras.name) AS cameras')
.map { |photos| {sol: photos.sol, earth_date: photos.earth_date, total_photos: photos.cnt, cameras: photos.cameras} }
end

def photos
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/api/v1/manifests_controller_spec.rb
Expand Up @@ -39,9 +39,9 @@

it "contains a record for each sol for which there are photos" do
expect(json["photo_manifest"]["photos"]).to contain_exactly(
{"sol" => 1, "total_photos" => 1, "cameras" => ["FHAZ"]},
{"sol" => 30, "total_photos" => 1, "cameras" => ["FHAZ"]},
{"sol" => 100, "total_photos" => 2, "cameras" => ["FHAZ"]}
{"sol" => 1, "earth_date"=>"2012-08-07", "total_photos" => 1, "cameras" => ["FHAZ"]},
{"sol" => 30, "earth_date"=>"2012-09-05", "total_photos" => 1, "cameras" => ["FHAZ"]},
{"sol" => 100, "earth_date"=>"2012-11-16", "total_photos" => 2, "cameras" => ["FHAZ"]}
)
end
end
Expand Down

0 comments on commit 3c5563c

Please sign in to comment.