From a6f6d457919973a61005a84da7e2464321cd87c0 Mon Sep 17 00:00:00 2001 From: GP Date: Wed, 27 Jan 2021 11:16:36 +1300 Subject: [PATCH] Check for no tag (#344) * check for no tag --- api/V1/Visits.ts | 6 +++++- test/test_visits.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api/V1/Visits.ts b/api/V1/Visits.ts index c2647773..31f2f45e 100644 --- a/api/V1/Visits.ts +++ b/api/V1/Visits.ts @@ -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; diff --git a/test/test_visits.py b/test/test_visits.py index fb1484f3..0bb58c58 100644 --- a/test/test_visits.py +++ b/test/test_visits.py @@ -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")