101
0/304
Loading content...
A trust-and-safety analytics team stores user activity in one table:
Actions columns:
Task:
Output requirements:
Supported submission environments:
Actions:
| user_id | post_id | action_date | action | extra |
|---------|---------|-------------|--------|--------|
| 1 | 1 | 2019-07-01 | view | null |
| 2 | 4 | 2019-07-04 | report | spam |
| 3 | 4 | 2019-07-04 | report | spam |
| 5 | 2 | 2019-07-04 | report | racism |
| 5 | 5 | 2019-07-04 | report | racism |[
{"report_reason":"spam","report_count":1},
{"report_reason":"racism","report_count":2}
]Spam has one distinct post (post 4) even though it appears in multiple rows. Racism appears on posts 2 and 5, so its distinct-post count is 2.
Actions:
| user_id | post_id | action_date | action | extra |
|---------|---------|-------------|--------|-------|
| 8 | 100 | 2019-07-03 | report | spam |
| 9 | 101 | 2019-07-04 | like | null |[]No row satisfies both yesterday's date and action='report', so the summary is empty.
Actions:
| user_id | post_id | action_date | action | extra |
|---------|---------|-------------|--------|---------------|
| 1 | 7 | 2019-07-04 | report | misinformation|
| 2 | 7 | 2019-07-04 | report | misinformation|
| 3 | 7 | 2019-07-04 | report | harassment |
| 4 | 8 | 2019-07-04 | report | harassment |[
{"report_reason":"misinformation","report_count":1},
{"report_reason":"harassment","report_count":2}
]A post can contribute to multiple reason groups if it was reported under multiple reasons.
Constraints