Advertisement
Guest User

Untitled

a guest
Aug 1st, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. def get_users_count(period):
  2.     if period == 'day':
  3.         today = datetime.now().strftime('%Y-%m-%d')
  4.         return db.users.count_documents({"reg_date": today})
  5.     elif period == 'month':
  6.         this_month = datetime.now().strftime('%Y-%m-')
  7.         all_days = []
  8.         for day in range(1,32):
  9.             all_days.append(f'{this_month}{day}')
  10.         return db.users.count_documents({"reg_date": {'$in': all_days}})
  11.     elif period == 'total':
  12.         return db.users.count_documents({'user_id': {'$exists':True}})
  13.     else:
  14.         return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement