Esempio n. 1
0
def rating_schdule():
    from mongoengine import Q
    for account in AccountItem.objects(
                Q(origin_oj='bestcoder') |
                Q(origin_oj='topcoder') |
                Q(origin_oj='codeforces')
            ).all():
        account_crawler(account.origin_oj, account.username)
Esempio n. 2
0
    def on_model_change(self, form, model):
        if len(model.password2):
            model.password = UserModel.generate_password(form.password2.data)
        elif not model.password:
            model.password = UserModel.generate_password('12345678')

        if model.bestcoder.user_id:
            account = AccountItem.objects(
                origin_oj='bestcoder',
                username=model.bestcoder.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='bestcoder',
                    username=model.bestcoder.user_id
                )
            account_crawler.delay(
                origin_oj='bestcoder',
                username=model.bestcoder.user_id
            )
            model.bestcoder.account = account
        else:
            model.bestcoder = Account(user_id='')

        if model.topcoder.user_id:
            account = AccountItem.objects(
                origin_oj='topcoder',
                username=model.topcoder.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='topcoder',
                    username=model.topcoder.user_id
                )
            account_crawler.delay(
                origin_oj='topcoder',
                username=model.topcoder.user_id
            )
            model.topcoder.account = account
        else:
            model.topcoder = Account(user_id='')

        if model.codeforces.user_id:
            account = AccountItem.objects(
                origin_oj='codeforces',
                username=model.codeforces.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='codeforces',
                    username=model.codeforces.user_id
                )
            account_crawler.delay(
                origin_oj='codeforces',
                username=model.codeforces.user_id
            )
            model.codeforces.account = account
        else:
            model.codeforces = Account(user_id='')

        if model.sdut.user_id:
            account = AccountItem.objects(
                origin_oj='sdut',
                username=model.sdut.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='sdut',
                    username=model.sdut.user_id
                )
            account_crawler.delay(
                origin_oj='sdut',
                username=model.sdut.user_id
            )
            model.sdut.account = account
        else:
            model.sdut = Account(user_id='')

        if model.hduoj.user_id:
            account = AccountItem.objects(
                origin_oj='hduoj',
                username=model.hduoj.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='hduoj',
                    username=model.hduoj.user_id
                )
            account_crawler.delay(
                origin_oj='hduoj',
                username=model.hduoj.user_id
            )
            model.hduoj.account = account
        else:
            model.hduoj = Account(user_id='')

        if model.poj.user_id:
            account = AccountItem.objects(
                origin_oj='poj',
                username=model.poj.user_id
            ).first()
            if not account:
                account = AccountItem.objects.create(
                    origin_oj='poj',
                    username=model.poj.user_id
                )
            account_crawler.delay(
                origin_oj='poj',
                username=model.poj.user_id
            )
            model.poj.account = account
        else:
            model.poj = Account(user_id='')
Esempio n. 3
0
def rating_schdule():
    from mongoengine import Q
    for account in AccountItem.objects(
            Q(origin_oj='bestcoder') | Q(origin_oj='topcoder')
            | Q(origin_oj='codeforces')).all():
        account_crawler(account.origin_oj, account.username)
Esempio n. 4
0
def hduoj_schedule():
    for account in AccountItem.objects(origin_oj='hduoj').all():
        account_crawler(account.origin_oj, account.username)
Esempio n. 5
0
def hduoj_schedule():
    for account in AccountItem.objects(origin_oj='hduoj').all():
        account_crawler(account.origin_oj, account.username)