Advertisement
denees_k

Untitled

Jul 2nd, 2025 (edited)
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. from datetime import datetime, timedelta
  2.  
  3.  
  4. one_week_ago = datetime.utcnow() - timedelta(days=7)
  5.  
  6. query = [
  7.     {
  8.         "$match": {
  9.             "is_moderated": True,
  10.             "timestamp": {"$gte": one_week_ago}
  11.         }
  12.     },
  13.     {
  14.         "$lookup": {
  15.             "from": "users",
  16.             "localField": "user_id",
  17.             "foreignField": "user_id",
  18.             "as": "user_info"
  19.         }
  20.     },
  21.     {
  22.         "$unwind": "$user_info"
  23.     },
  24.     {
  25.         "$group": {
  26.             "_id": "$user_info.username",
  27.             "moderated_messages_count": {"$sum": 1}
  28.         }
  29.     },
  30. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement