Facebook Groups Top Contributor Badges from Rolling 28-Day Points

Last updated: November 29, 2026

Quick Overview

Each Facebook Group member earns daily activity points. For every group and day, award a Top Contributor badge to members in the top 1 percent by trailing 28-day points (with at least 10 points, and always the top member), then count how many badges were newly gained each day.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Each Facebook Group member earns daily activity points. For every group and day, award a Top Contributor badge to members in the top 1 percent by trailing 28-day points (with at least 10 points, and always the top member), then count how many badges were newly gained each day.

Groups' Top Contributor badge rewards members who help their communities, and computing it daily mixes several window patterns at once. The interviewer checks a dense member-day series for the rolling sum, ranking within group and day, and LAG on the badge flag to detect new grants.

What the Interviewer Expects
  • Builds a dense member by day series so the 28-row frame equals 28 calendar days
  • Computes rolling points with ROWS BETWEEN 27 PRECEDING AND CURRENT ROW
  • Ranks eligible members within each group and day using CUME_DIST and RANK
  • Applies the top-1-percent rule with a minimum score and a top-member fallback
  • Uses LAG on the badge flag to count newly gained badges
Key Topics to Cover
rolling SUM
CUME_DIST
RANK
LAG state changes
Facebook Groups
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you add hysteresis so members do not flicker in and out of the badge day to day?
  • How would you stop the dense series from exploding for groups with millions of mostly inactive members?
  • How would you measure whether receiving the badge increases future contributions?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Table: group_member_points(group_id, user_id, ds, points), one row per member per day with points > 0. Members who stop contributing must still be evaluated on later days because their 28-day total ...

Approach
  1. Dense grid per (group_id, user_id) from first point day to the max date, zero-filled.
  2. rolling = SUM(points) OVER (... ROWS BETWEEN 27 PRECEDING AND CURRENT ROW).
  3. Among members with rollin...

Submit Your Answer
Markdown supported