Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in get_tags() #245

Open
peterdesmet opened this issue Jun 16, 2022 · 2 comments
Open

Bug in get_tags() #245

peterdesmet opened this issue Jun 16, 2022 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@peterdesmet
Copy link
Member

Reported by @aubrivliz:

Ik denk dat er een bug is in de query van get_tag()

tag.tag_type AS tag_type,

Als je dit uitvoert:

tags <- get_tags(connection = my_con, tag_type = "acoustic-archival")

Dan krijg je niet enkel de acoustic-archival tags terug maar ook de sensor-tags van acoustic telemetry.

In het schema common heb je de volgende table:

SELECT id_pk, name, description, telemetry_type_fk FROM common.tag_device_type

image001

Het zou moeten gefilterd worden op telemetry_type_fk

image002

Dus ik denk dat er nog een join mist in de query 😊

@peterdesmet peterdesmet added the bug Something isn't working label Jun 16, 2022
@peterdesmet peterdesmet self-assigned this Jun 16, 2022
@peterdesmet peterdesmet added this to the Summer 2022 milestone Jun 16, 2022
@peterdesmet
Copy link
Member Author

@aubrivliz the three categories are currently defined like this:

etn/inst/sql/tag.sql

Lines 4 to 8 in 6553d4f

CASE
WHEN tag_type.name = 'id-tag' THEN 'acoustic'
WHEN tag_type.name = 'sensor-tag' AND acoustic_tag_id IS NOT NULL THEN 'acoustic-archival'
WHEN tag_type.name = 'sensor-tag' THEN 'archival'
END AS tag_type,

What would be a better way to assign those categories?

@aubrivliz
Copy link
Collaborator

aubrivliz commented Jun 16, 2022

This should be:

  CASE
    WHEN tag_type.id_pk = 1 THEN 'acoustic telemetry'
    WHEN tag_type.id_pk = 2 THEN 'acoustic telemetry'
    WHEN tag_type.id_pk = 3 THEN 'archival data'
    WHEN tag_type.id_pk = 4 THEN 'acoustic Archival'
    WHEN tag_type.id_pk = 5 THEN 'pit telemetry'
    WHEN tag_type.id_pk = 6 THEN 'radio telemetry'  
  END AS tag_type

But the tag_type field is misinterpreted.

If we speak of tag type this should be: "id-tag", "sensor-tag", "pit tag", "radio tag".
Those tags can be used in multiple telemetry types: "acoustic telemetry", "archival data" ...

Ideally there should be 2 fields, "tag_type" and "tag_telemetry_type".

this should be the correct way to add those fields:

SELECT
  tag_type.name as tag_type,
  tag_telemetry_type.name as tag_telemetry_type 
 FROM
  common.tag_device_limited AS tag_device
  LEFT JOIN common.tag_device_type as tag_type ON tag_device.tag_device_type_fk = tag_type.id_pk
  LEFT JOIN common.telemetry_type as tag_telemetry_type on  tag_telemetry_type.id_pk = tag_type.telemetry_type_fk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants