from app import db, crontab
from app.models.program import Program
from datetime import datetime

@crontab.job(minute="0", hour="4")
def update_progrank():
    for p in Program.query.all():
        p.progrank = 0
        p.progrank_date = datetime.now()
        db.session.merge(p)
    db.session.commit()
