ankane / ahoy

Simple, powerful, first-party analytics for Rails
MIT License
4.24k stars 377 forks source link

where_properties array IN #508

Closed silva96 closed 2 years ago

silva96 commented 2 years ago

Hey, I wonder if this is possible, I register events for "products" using a property in the jsonb called: product_id

I would love to return events for products 1 and 2, for example

Ahoy::Event.where_event('Product View', product_id: [1, 2])

Reading the code, I see you just dump the properties as json and match with @> so the array wont work in this case, any ideas of how can I achieve this?

Regards

ankane commented 2 years ago

Hey @silva96, you can use or:

Ahoy::Event.where_event('Product View', product_id: 1).or(Ahoy::Event.where_event('Product View', product_id: 2))

Or write custom SQL