zooniverse / wildcam-gorongosa-education

This is WildCam Labs, the education/exploration-oriented extension of the WildCam Gorongosa project.
https://lab.wildcamgorongosa.org/
Apache License 2.0
0 stars 1 forks source link

Fix 305: Don't download empty camera data! #306

Closed shaunanoordin closed 7 years ago

shaunanoordin commented 7 years ago

PR Overview

Fixes #305

When accessing the Carto database for: counting results, downloading CSV results, and creating Assignments; the counted/downloaded/selected results now ignore empty cameras.

Status

Ready for review

Details

The cause of the problem is in the use of LEFT JOIN instead of INNER JOIN when we're, e.g. downloading results in a CSV file.

Let's say we have a setup like this:

CAMERA | dist_water
-------------------
A      | 10
B      | 30

SUBJECT | count | camera
------------------------
Lion    | 5     | A
Baboon  | 13    | A

When we use CAMERA LEFT JOIN SUBJECT we'll get

SUBJECT | count | CAMERA | dist_water
-------------------------------------
Lion    | 5     | A      | 10
Baboon  | 13    | A      | 10
null    | null  | B      | 30

There's an invalid row at the end of results. (i.e. the empty row won't make sense when creating Assignments or when creating a CSV results file.) We need to use CAMERA INNER JOIN SUBJECT to get the desired

SUBJECT | count | CAMERA | dist_water
-------------------------------------
Lion    | 5     | A      | 10
Baboon  | 13    | A      | 10

This change affects the following SQL Queries in mapexplorer.config.json:

NOTE! The following SQL Query still uses LEFT JOIN since we do want the empty cameras: