コード例 #1
0
ファイル: manage.py プロジェクト: hasgeek/hasjob
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()


# Legacy call
@manager.option("-e", "--env", default="dev", help="runtime env [default 'dev']")
def sweep(env):
    """Sweep user sessions to close all inactive sessions [deprecated]"""
    sessions(env)


@periodic.option("-e", "--env", default="dev", help="runtime env [default 'dev']")
def impressions(env):
    """Recount impressions for jobposts in the dirty list (5m)"""
    manager.init_for(env)
    views.helper.update_dirty_impression_counts()


if __name__ == "__main__":
    db.init_app(app)
    manager = init_manager(app, db, init_for, hasjob=hasjob, models=models, forms=forms, views=views)
    manager.add_command("periodic", periodic)
    manager.run()
コード例 #2
0
ファイル: manage.py プロジェクト: saurabh17a/hasjob
    es = models.EventSession
    # Close all sessions that have been inactive for >= 30 minutes
    es.query.filter(es.ended_at.is_(None), es.active_at <
                    (utcnow() - timedelta(minutes=30))).update(
                        {es.ended_at: es.active_at})
    db.session.commit()


@periodic.command
def impressions():
    """Recount impressions for jobposts in the dirty list (5m)"""
    views.helper.update_dirty_impression_counts()


@periodic.command
def campaignviews():
    """Reset campaign views after more than 30 days since last view (1d)"""
    views.helper.reset_campaign_views()


if __name__ == '__main__':
    db.init_app(app)
    manager = init_manager(app,
                           db,
                           hasjob=hasjob,
                           models=models,
                           forms=forms,
                           views=views)
    manager.add_command('periodic', periodic)
    manager.run()