Closed PunitTailor55 closed 9 months ago
Fetch the last 48 hours login user details add following code.
add function in User.py
```
def all_login_user(cls):
now = datetime.now()
print(now)
date = datetime.utcnow() - timedelta(hours=48)
#date = now - timedelta(days=3)
userlogin = dbsession.query(cls).filter(User.last_login >=date).all()
return [user for user in userlogin if user.is_admin() is False] ```
Add following code in UserHandlers.py
class HomeHandler(BaseHandler)
function where render the admin/home.html
file.
userlogin = len(User.all_login_user()),
Rander in admin/index.html
<div style="margin-bottom: 5px;"><i class="fa fa-fw fa-user"></i>{{ _("Total Login Users") }}: {{userlogin}}
I am trying to develop total login users using the last login date. In database,
last_login
column has datetime function used. So, I have converted date using datetime functiondate = now.strftime('%Y/%m/%d')
but it still return 0. I am trying to fetch current date login users. I have successfully created verified users and registered users.