Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_users_count(period):
- if period == 'day':
- today = datetime.now().strftime('%Y-%m-%d')
- return db.users.count_documents({"reg_date": today})
- elif period == 'month':
- this_month = datetime.now().strftime('%Y-%m-')
- all_days = []
- for day in range(1,32):
- all_days.append(f'{this_month}{day}')
- return db.users.count_documents({"reg_date": {'$in': all_days}})
- elif period == 'total':
- return db.users.count_documents({'user_id': {'$exists':True}})
- else:
- return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement