Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime, timedelta
- one_week_ago = datetime.utcnow() - timedelta(days=7)
- query = [
- {
- "$match": {
- "is_moderated": True,
- "timestamp": {"$gte": one_week_ago}
- }
- },
- {
- "$lookup": {
- "from": "users",
- "localField": "user_id",
- "foreignField": "user_id",
- "as": "user_info"
- }
- },
- {
- "$unwind": "$user_info"
- },
- {
- "$group": {
- "_id": "$user_info.username",
- "moderated_messages_count": {"$sum": 1}
- }
- },
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement