Fix where clause for gamification rule