-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingdatabaseissues related to the database, data cleaning, views, mappingissues related to the database, data cleaning, views, mapping
Description
This test fails in ETN:
test_that("get_acoustic_detections() does not return duplicate detections when tags are reused", {
# A69-1601-29925 (tag_serial_number = 1145373) is associated with two animals:
# - 393 (2012_leopoldkanaal) from 2012-08-21 14:27:00 to 2012-12-10
# - 394 (2012_leopoldkanaal) from 2012-12-14 13:30:00 to open
# Detections should be joined with acoustic_tag_id AND datetime, so that they
# are not duplicated. Note: for df_393 we use a start_date to limit records.
df_both <- get_acoustic_detections(acoustic_tag_id = "A69-1601-29925")
df_393 <- get_acoustic_detections(acoustic_tag_id = "A69-1601-29925",
start_date = "2012-12-01",
end_date = "2012-12-10")
df_394 <- get_acoustic_detections(acoustic_tag_id = "A69-1601-29925",
start_date = "2012-12-14")
# Expect no duplicates
expect_identical(nrow(df_both),
nrow(df_both %>% dplyr::distinct(detection_id)))
# Return correct animal within range
expect_identical(df_393 %>% dplyr::distinct(animal_id) %>% dplyr::pull(), 393L)
expect_identical(df_394 %>% dplyr::distinct(animal_id) %>% dplyr::pull(), 394L)
})Because 4 fields, including animal_id, are completely empty when using the new view:
> dplyr::glimpse(old)
Rows: 3,261
Columns: 21
$ detection_id <int> 44376800, 44376819, 44376849, 44376860, 44376861, 44376863, 44376868, 4…
$ date_time <dttm> 2012-12-01 00:15:18, 2012-12-01 00:51:49, 2012-12-01 01:40:02, 2012-12…
$ tag_serial_number <chr> "1145373", "1145373", "1145373", "1145373", "1145373", "1145373", "1145…
$ acoustic_tag_id <chr> "A69-1601-29925", "A69-1601-29925", "A69-1601-29925", "A69-1601-29925",…
$ animal_project_code <chr> "2012_leopoldkanaal", "2012_leopoldkanaal", "2012_leopoldkanaal", "2012…
$ animal_id <int> 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 3…
$ scientific_name <chr> "Anguilla anguilla", "Anguilla anguilla", "Anguilla anguilla", "Anguill…
$ acoustic_project_code <chr> "leopold", "leopold", "leopold", "leopold", "leopold", "leopold", "leop…
$ receiver_id <chr> "VR2W-115445", "VR2W-115445", "VR2W-115445", "VR2W-115445", "VR2W-11544…
$ station_name <chr> "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36",…
$ deploy_latitude <dbl> 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 5…
$ deploy_longitude <dbl> 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826,…
$ depth_in_meters <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ sensor_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ sensor_unit <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ sensor2_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ sensor2_unit <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ signal_to_noise_ratio <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ source_file <chr> "VR2W_115445_20140610_1.csv", "VR2W_115445_20140610_1.csv", "VR2W_11544…
$ qc_flag <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, F…
$ deployment_id <int> 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811,…
> dplyr::glimpse(new)
Rows: 3,261
Columns: 20
$ detection_id <int> 44376800, 44376819, 44376849, 44376860, 44376861, 44376863, 44376868, 4…
$ date_time <dttm> 2012-12-01 00:15:18, 2012-12-01 00:51:49, 2012-12-01 01:40:02, 2012-12…
$ tag_serial_number <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ acoustic_tag_id <chr> "A69-1601-29925", "A69-1601-29925", "A69-1601-29925", "A69-1601-29925",…
$ animal_project_code <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ animal_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ scientific_name <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ acoustic_project_code <chr> "leopold", "leopold", "leopold", "leopold", "leopold", "leopold", "leop…
$ receiver_id <chr> "VR2W-115445", "VR2W-115445", "VR2W-115445", "VR2W-115445", "VR2W-11544…
$ station_name <chr> "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36", "bh-36",…
$ deploy_latitude <dbl> 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 51.33464, 5…
$ deploy_longitude <dbl> 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826, 3.76826,…
$ sensor_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ sensor_unit <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ sensor2_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ sensor2_unit <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…
$ signal_to_noise_ratio <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ source_file <chr> "VR2W_115445_20140610_1.csv", "VR2W_115445_20140610_1.csv", "VR2W_11544…
$ qc_flag <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, F…
$ deployment_id <int> 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811,…- tag_serial_number
- animal_project_code
- animal_id
- scientific_name
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdatabaseissues related to the database, data cleaning, views, mappingissues related to the database, data cleaning, views, mapping