Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Step 1: Define the base interaction query, potentially with filtering via ransack
- interactions_query = Interaction.ransack(interactions_event_query).result
- # Step 2: Join employees and group by interaction_type and compare_key to get total counts
- total_interactions = interactions_query
- .joins(:employee) # Simplified as a normal join now
- .group('interaction_type', "employees.#{compare_key}")
- .count
- # Step 3: For unique interactions, we use ActiveRecord's distinct method and the same grouping
- unique_interactions = interactions_query
- .select('distinct interaction_type, employee_id') # Unique interactions based on type and employee
- .joins(:employee)
- .group('interaction_type', "employees.#{compare_key}")
- .count
Advertisement
Add Comment
Please, Sign In to add comment