*Perfect *

import datetime
limit = request.now - datetime.timedelta(minutes=30)
query = db.auth_event.time_stamp > limit
query &= db.auth_event.description.contains('Logged-')
events = db(query).select(db.auth_event.user_id, db.auth_event.description,
    orderby=db.auth_event.user_id|db.auth_event.time_stamp)
users = []for i in range(len(events)):
    last_event = ((i == len(events) - 1) or
                   events[i+1].user_id != events[i].user_id)
    if last_event and 'Logged-in' in events[i].description:
        users.append(events[i].user_id)
logged_in_users = db(db.auth_user.id.belongs(users)).select()


Best Regards,

On Wed, Dec 12, 2012 at 8:50 PM, guruyaya <guruy...@gmail.com> wrote:

> I'm not sure about this. You think of perfect solutions, when most people
> will settle for simpler solution, that may not be perfect. I imagine a line
> in the model, that updates a datetime field, every time a user does
> something in the website, and then finding out who had his last activity in
> the last 5 minutes.
>
> --
>
>
>
>

-- 



Reply via email to