Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Check for no tag (#344)
Browse files Browse the repository at this point in the history
* check for no tag
  • Loading branch information
GP authored Jan 26, 2021
1 parent 6cd373c commit a6f6d45
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/V1/Visits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,11 @@ class VisitEvent {
this.audioBaitEvents = [];
this.recStart = trackTimes.recStart;
this.trackID = track.id;
this.what = taggedAs.what;
if (taggedAs) {
this.what = taggedAs.what;
} else {
this.what = null;
}
this.assumedTag = tag.what;
this.confidence = Math.round(tag.confidence * 100);
this.start = trackTimes.trackStart;
Expand Down
18 changes: 18 additions & 0 deletions test/test_visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ def test_multiple_animals(self, helper):
assert visit["what"] == "cat"
assert len(visit["events"]) == 3

def test_no_tag(self, helper):
admin = helper.admin_user()
cosmo = helper.given_new_user(self, "cosmo")
cosmo_group = helper.make_unique_group_name(self, "cosmos_group")
cosmo.create_group(cosmo_group)
device = helper.given_new_device(self, "cosmo_device", cosmo_group)
# check that a recording with 1 untagged track, 1 unidentified and 1 cat, assumes the unidentified and untagged is a cat
rec, _, _ = helper.upload_recording_with_tag(device, admin, "unidentified")
track = admin.can_add_track_to_recording(rec, start_s=80)
track = admin.can_add_track_to_recording(rec, start_s=80)
admin.can_tag_track(track, what="cat")

response = cosmo.query_visits(return_json=True, deviceIds=device.get_id())
assert response["numVisits"] == 1
visit = response["rows"][str(device.get_id())]["visits"][0]
assert visit["what"] == "cat"
assert len(visit["events"]) == 3

def test_visit_grouping(self, helper):
admin = helper.admin_user()
cosmo = helper.given_new_user(self, "cosmo")
Expand Down

0 comments on commit a6f6d45

Please sign in to comment.