Badge Query for Profile Views

Is there a way to give a badge if a profile has more than X views?

2 Likes

Hi Coder,

You should be able to use the following SQL to create a custom badge that’s granted once the user has more than X number of views.

Badge Query for Profile Views

SELECT 
  user_profile_views.user_profile_id AS user_id, 
  COUNT(user_profile_views.user_profile_id),
  current_timestamp granted_at
FROM user_profile_views
GROUP BY user_profile_views.user_profile_id
HAVING  COUNT(user_profile_views.user_profile_id) > X 
ORDER BY COUNT(user_profile_views.user_profile_id) DESC

In case you’re curious, here’s a corresponding Data Explorer SQL query for this as well.

SQL Data Explorer Query for Profile Views

-- [params]
-- int :view_count = X

SELECT 
  user_profile_views.user_profile_id AS user_id, 
  COUNT(user_profile_views.user_profile_id) AS "Views",
FROM user_profile_views
GROUP BY user_profile_views.user_profile_id
HAVING  COUNT(user_profile_views.user_profile_id) > :view_count
ORDER BY COUNT(user_profile_views.user_profile_id) DESC

I hope this helps!

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.