Fetch solutions per user

Hey there!

Searched through the whole forum and did a bit of development myself but cannot create a query to fetch all users with the number of solutions given by them in a certain period of time. Thanks for help!

3 Likes

You can get solved topics from the user_actions table. Solved topics in that table have their action_type set to 15.

Here’s a general query for getting solved counts for users within a given time period. You’ll need to set the start_date and end_date parameters before running the query. Those parameters should be in the form of yyyy-mm--dd. For example 2020-02-18.

--[params]
-- date :start_date
-- date :end_date

SELECT
user_id,
COUNT(user_id) AS solved_count
FROM user_actions
WHERE created_at::date BETWEEN :start_date AND :end_date
AND action_type = 15
GROUP BY user_id
ORDER BY solved_count DESC
5 Likes