Team-TAU/tau

[BUG] Cannot filter twitch-events with documented query params (for querying raid event data)

Closed this issue · 3 comments

Describe the bug

I am unable to query for filtered raid-related data by passing in the documented query params recipient_user_name or recipient_user_id, assuming these are the fields I can use to get data for incoming raids.

Here is an example SQL query that I am trying to retrieve:

select * from twitchevents_twitchevent 
  where event_type = 'channel-raid' 
and 
  event_data @> '{"to_broadcaster_user_login": "techygrrrl"}' 
order by created desc;

I have attempted the following queries:

  • /api/v1/twitch-events?event_type=channel-raid&recipient_user_name=techygrrrl – empty results
  • /api/v1/twitch-events?event_type=channel-raid&recipient_user_id=176082690 – empty results

And other queries (the opposite direction):

  • /api/v1/twitch-events?event_type=channel-raid&raid_broadcaster_id=176082690 – does not appear to be filtering as I see raids both to and from my channel
  • /api/v1/twitch-events?event_type=channel-raid&raid_broadcaster_name=techygrrrl – does not appear to be filtering as I see raids both to and from my channel

I suspect there is a bug where TAU is converting query params to jsonb fields for lookups (here). I am not familiar with this magical feature in Django so I am unable to fully know what's going on in this area of the code.

To Reproduce

Steps to reproduce the behaviour:

Perform the above-mentioned queries on your own TAU instance replacing the following values with your own:

  • Change 176082690 to your own user_id
  • Change techygrrrl to your own login name or display name (mine is the same all-lowercase value for both so it doesn't make a difference and the issue wouldn't be in that area)

Expected behaviour

I expect to receive information about my incoming raids.

Screenshots

I am referring to the documentation that is generated in the Github Action workflows. Here's a screenshot:

image

Deployment:

  • Deployment Type: Railway
  • Deployment Details: Running the latest TAU version available on March 27

Additional context

Here's an example SQL query for lookup by ID:

select * from twitchevents_twitchevent 
  where event_type = 'channel-raid' 
and 
  event_data @> '{"to_broadcaster_user_id": "176082690"}' 
order by created desc;

image

And querying by user name (which appears to be the display name but mine is the same as my login). This returns the same data as the other 2 queries:

select * from twitchevents_twitchevent 
  where event_type = 'channel-raid' 
and 
  event_data @> '{"to_broadcaster_user_name": "techygrrrl"}' 
order by created desc;

Thanks for opening the issue. I suspect this has to do with how Django filters works (how we easily filter thing for Django Rest Framework). I'll take a look this afternoon and figure out a fix soon.