def sessions(env): """Sweep user sessions to close all inactive sessions (10m)""" manager.init_for(env) es = models.EventSession # Close all sessions that have been inactive for >= 30 minutes es.query.filter(es.ended_at == None, es.active_at < (datetime.utcnow() - timedelta(minutes=30))).update( # NOQA {es.ended_at: es.active_at} ) db.session.commit()
def sweep(env): """Sweep the user database to close all the inactive sessions""" manager.init_for(env) print "Sweeping all the inactive sessions" es = models.EventSession # Inactive sessions are only kept for 30mins es.query.filter((es.ended_at==None) & (es.active_at<(datetime.utcnow() - \ timedelta(minutes=30)))).update({es.ended_at: es.active_at}) try: db.session.commit() except IntegrityError: print "Could not commit changes made. Please try again later." db.session.rollback()
def impressions(env): """Recount impressions for jobposts in the dirty list (5m)""" manager.init_for(env) views.helper.update_dirty_impression_counts()