Esempio n. 1
0
    from maproulette.models import Task, Challenge
    for challenge in db.session.query(Challenge):
        counter = 0
        for task in db.session.query(Task).filter_by(
                challenge_slug=challenge.slug):
            task.set_location()
            counter += 1
            # commit every 1000
            if not counter % 1000:
                db.session.commit()
        db.session.commit()
        print 'done. Location for %i tasks in challenge %s set' %\
            (counter, challenge.title)


@manager.command
def clean_sessions():
    """Remove all stored sessions"""
    session_dir = './sessiondata'
    for f in os.listdir(session_dir):
        file_path = os.path.join(session_dir, f)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
        except Exception, e:
            print e


if __name__ == "__main__":
    manager.run()
Esempio n. 2
0
            Task.identifier, Task.challenge_slug).having(max(Action.timestamp) < stale_threshold).all():
        task.append_action(Action("available"))
        db.session.add(task)
        print "setting task %s to available" % (task.identifier)
        counter += 1
    db.session.commit()
    print 'done. %i tasks made available' % counter


@manager.command
def populate_task_location():
    """This command populates the new location field for each task"""
    from maproulette import db
    from maproulette.models import Task, Challenge
    for challenge in db.session.query(Challenge):
        counter = 0
        for task in db.session.query(Task).filter_by(
                challenge_slug=challenge.slug):
            task.set_location()
            counter += 1
            # commit every 1000
            if not counter % 1000:
                db.session.commit()
        db.session.commit()
        print 'done. Location for %i tasks in challenge %s set' %\
            (counter, challenge.title)


if __name__ == "__main__":
    manager.run()