You're building a content moderation system for a social media platform. The platform tracks all user interactions with posts in an Actions table, including views, likes, comments, and most importantly - reports.
Your mission: Generate a daily report showing how many posts were reported yesterday, grouped by the reason for reporting. This helps the moderation team understand what types of content issues are most common.
Table: Actions
| Column Name | Type |
|---|---|
| user_id | int |
| post_id | int |
| action_date | date |
| action | enum |
| extra | varchar |
The action column contains values like 'view', 'like', 'reaction', 'comment', 'report', 'share'. When action = 'report', the extra column contains the reason for the report (e.g., 'spam', 'violence', 'hate speech').
Given: Today is 2019-07-05
Return: Number of posts reported on 2019-07-04, grouped by report reason, in any order.
Input & Output
Visualization
Time & Space Complexity
Linear scan with database optimizations, potentially much faster with indexes on action_date and action columns
Where k is the number of unique report reasons for grouping results
Constraints
- The Actions table may contain duplicate rows
- action is an ENUM with values: 'view', 'like', 'reaction', 'comment', 'report', 'share'
- extra column is optional and contains additional information like report reasons
- Today's date is fixed as 2019-07-05, so yesterday is 2019-07-04
- Return results in any order
- If no reports found for yesterday, return empty result set