Team-TAU / tau

TAU- Twitch API Unifier, a containerized relay/proxy to unify the WebHook- and WebSocket-based real-time Twitch APIs under a single (local) WebSocket connection.
MIT License
149 stars 38 forks source link

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

Closed techygrrrl closed 2 years ago

techygrrrl commented 2 years ago

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:

And other queries (the opposite direction):

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:

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:

Additional context

techygrrrl commented 2 years ago

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;
FiniteSingularity commented 2 years ago

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.

techygrrrl commented 2 years ago

Documentation reference: https://techygrrrl.github.io/tau/api/v1/#get-apiv1twitch-events