当前位置: 首页>>代码示例>>Python>>正文


Python AccountPrototype.live_query方法代码示例

本文整理汇总了Python中the_tale.accounts.prototypes.AccountPrototype.live_query方法的典型用法代码示例。如果您正苦于以下问题:Python AccountPrototype.live_query方法的具体用法?Python AccountPrototype.live_query怎么用?Python AccountPrototype.live_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.accounts.prototypes.AccountPrototype的用法示例。


在下文中一共展示了AccountPrototype.live_query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: portal_day_started

# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import live_query [as 别名]
def portal_day_started(sender, **kwargs): # pylint: disable=W0613
    accounts_query = AccountPrototype.live_query().filter(active_end_at__gt=datetime.datetime.now(),
                                                          ban_game_end_at__lt=datetime.datetime.now(),
                                                          ban_forum_end_at__lt=datetime.datetime.now(),
                                                          premium_end_at__lt=datetime.datetime.now())

    accounts_number = accounts_query.count()
    if accounts_number < 1:
        return

    account_model = accounts_query[random.randint(0, accounts_number-1)]

    account = AccountPrototype(model=account_model)

    settings[portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY] = str(account.id)

    environment.workers.accounts_manager.cmd_run_account_method(account_id=account.id,
                                                                method_name=AccountPrototype.prolong_premium.__name__,
                                                                data={'days': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY})

    message = u'''
Поздравляем!

Ваш герой выбран героем дня и Вы получаете %(days)d дней подписки!
''' % {'days': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY}

    MessagePrototype.create(get_system_user(), account, message)
开发者ID:Alkalit,项目名称:the-tale,代码行数:29,代码来源:signal_processors.py

示例2: get_referers_statistics

# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import live_query [as 别名]
def get_referers_statistics():

    raw_statistics = (
        AccountPrototype.live_query().values("referer_domain").order_by().annotate(models.Count("referer_domain"))
    )

    statistics = {}

    for s in raw_statistics:
        domain = s["referer_domain"]

        count = s["referer_domain__count"]

        query = AccountPrototype.live_query().filter(referer_domain=domain)

        if domain is None:
            count = query.count()

        target_domain = domain

        if target_domain and target_domain.endswith(
            "livejournal.com"
        ):  # hide all domains username.livejournal.com (to hide there payment info)
            target_domain = "livejournal.com"

        st = RefererStatistics(
            domain=target_domain,
            count=count,
            active_accounts=query.filter(active_end_at__gt=datetime.datetime.now()).count(),
            premium_accounts=query.filter(premium_end_at__gt=datetime.datetime.now()).count(),
            active_and_premium=query.filter(
                active_end_at__gt=datetime.datetime.now(), premium_end_at__gt=datetime.datetime.now()
            ).count(),
            premium_currency=BankAccountPrototype._money_received(
                from_type=BANK_ENTITY_TYPE.XSOLLA, accounts_ids=query.values_list("id", flat=True)
            ),
        )

        if st.domain in statistics:
            statistics[st.domain] = statistics[st.domain] + st
        else:
            statistics[st.domain] = st

    statistics = sorted(list(statistics.values()), key=lambda s: -s.count)

    return statistics
开发者ID:Tiendil,项目名称:the-tale,代码行数:48,代码来源:views.py

示例3: index

# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import live_query [as 别名]
    def index(self):

        registration_attemps_number = AccountPrototype._model_class.objects.all().aggregate(models.Max('id'))['id__max']
        accounts_total = AccountPrototype._model_class.objects.all().count()
        accounts_bots = AccountPrototype._model_class.objects.filter(is_bot=True).count()
        accounts_registered = AccountPrototype.live_query().count()
        accounts_active = AccountPrototype.live_query().filter(active_end_at__gt=datetime.datetime.now()).count()
        accounts_premium = AccountPrototype.live_query().filter(premium_end_at__gt=datetime.datetime.now()).count()
        accounts_active_and_premium = AccountPrototype.live_query().filter(active_end_at__gt=datetime.datetime.now(),
                                                                           premium_end_at__gt=datetime.datetime.now()).count()

        accounts_referrals = AccountPrototype.live_query().exclude(referral_of=None).count()
        accounts_referrals_and_premium = AccountPrototype.live_query().exclude(referral_of=None).filter(premium_end_at__gt=datetime.datetime.now()).count()
        accounts_referrals_and_active = AccountPrototype.live_query().exclude(referral_of=None).filter(active_end_at__gt=datetime.datetime.now(),
                                                                                                       premium_end_at__gt=datetime.datetime.now()).count()

        gold = {}
        gold_total_spent = 0
        gold_total_received = 0
        real_gold_total_spent = 0
        real_gold_total_received = 0

        for record in BANK_ENTITY_TYPE.records:
            spent = -BankAccountPrototype._money_spent(from_type=record)
            received = BankAccountPrototype._money_received(from_type=record)
            gold[record.text] = {'spent': spent, 'received': received}

            gold_total_spent += spent
            gold_total_received += received

            if record.is_real:
                real_gold_total_spent += spent
                real_gold_total_received += received

        gold_in_game = gold_total_received - gold_total_spent
        real_gold_in_game = real_gold_total_received - real_gold_total_spent

        return self.template('developers_info/index.html',
                             {'registration_attemps_number': registration_attemps_number,
                              'accounts_total': accounts_total,
                              'accounts_bots': accounts_bots,
                              'accounts_registered': accounts_registered,
                              'accounts_active': accounts_active,
                              'accounts_premium': accounts_premium,
                              'accounts_active_and_premium': accounts_active_and_premium,
                              'accounts_referrals': accounts_referrals,
                              'accounts_referrals_and_premium': accounts_referrals_and_premium,
                              'accounts_referrals_and_active': accounts_referrals_and_active,
                              'gold': gold,
                              'gold_total_spent': gold_total_spent,
                              'gold_total_received': gold_total_received,
                              'gold_in_game': gold_in_game,
                              'real_gold_in_game': real_gold_in_game,
                              'referers_statistics': get_referers_statistics(),
                              'invoice_statistics': get_invoice_statistics(),
                              'invoice_count': InvoiceQuery.count(),
                              'repeatable_payments_statistics': get_repeatable_payments_statistics(),
                              'PAYMENT_GROUPS': PAYMENT_GROUPS,
                              'PREMIUM_DAYS_FOR_HERO_OF_THE_DAY': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY,
                              'page_type': 'index'})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:62,代码来源:views.py

示例4: recalculate_accounts_might

# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import live_query [as 别名]
def recalculate_accounts_might():

    for account_model in AccountPrototype.live_query():
        account = AccountPrototype(model=account_model)

        new_might = calculate_might(account)

        if account.might != new_might:
            account.set_might(new_might)
            account.cmd_update_hero()

    recalculate_folclor_rating()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:14,代码来源:might.py

示例5: index

# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import live_query [as 别名]
    def index(self):

        registration_attemps_number = AccountPrototype._model_class.objects.all().aggregate(models.Max("id"))["id__max"]
        accounts_total = AccountPrototype._model_class.objects.all().count()
        accounts_bots = AccountPrototype._model_class.objects.filter(is_bot=True).count()
        accounts_registered = AccountPrototype.live_query().count()
        accounts_active = AccountPrototype.live_query().filter(active_end_at__gt=datetime.datetime.now()).count()
        accounts_premium = AccountPrototype.live_query().filter(premium_end_at__gt=datetime.datetime.now()).count()
        accounts_active_and_premium = (
            AccountPrototype.live_query()
            .filter(active_end_at__gt=datetime.datetime.now(), premium_end_at__gt=datetime.datetime.now())
            .count()
        )

        accounts_referrals = AccountPrototype.live_query().exclude(referral_of=None).count()
        accounts_referrals_and_premium = (
            AccountPrototype.live_query()
            .exclude(referral_of=None)
            .filter(premium_end_at__gt=datetime.datetime.now())
            .count()
        )
        accounts_referrals_and_active = (
            AccountPrototype.live_query()
            .exclude(referral_of=None)
            .filter(active_end_at__gt=datetime.datetime.now(), premium_end_at__gt=datetime.datetime.now())
            .count()
        )

        gold = {}
        gold_total_spent = 0
        gold_total_received = 0
        real_gold_total_spent = 0
        real_gold_total_received = 0

        for record in BANK_ENTITY_TYPE.records:
            spent = -BankAccountPrototype._money_spent(from_type=record)
            received = BankAccountPrototype._money_received(from_type=record)
            gold[record.text] = {"spent": spent, "received": received}

            gold_total_spent += spent
            gold_total_received += received

            if record.is_real:
                real_gold_total_spent += spent
                real_gold_total_received += received

        gold_in_game = gold_total_received - gold_total_spent
        real_gold_in_game = real_gold_total_received - real_gold_total_spent

        return self.template(
            "developers_info/index.html",
            {
                "registration_attemps_number": registration_attemps_number,
                "accounts_total": accounts_total,
                "accounts_bots": accounts_bots,
                "accounts_registered": accounts_registered,
                "accounts_active": accounts_active,
                "accounts_premium": accounts_premium,
                "accounts_active_and_premium": accounts_active_and_premium,
                "accounts_referrals": accounts_referrals,
                "accounts_referrals_and_premium": accounts_referrals_and_premium,
                "accounts_referrals_and_active": accounts_referrals_and_active,
                "gold": gold,
                "gold_total_spent": gold_total_spent,
                "gold_total_received": gold_total_received,
                "gold_in_game": gold_in_game,
                "real_gold_in_game": real_gold_in_game,
                "referers_statistics": get_referers_statistics(),
                "invoice_statistics": get_invoice_statistics(),
                "invoice_count": InvoiceQuery.count(),
                "repeatable_payments_statistics": get_repeatable_payments_statistics(),
                "PAYMENT_GROUPS": PAYMENT_GROUPS,
                "PREMIUM_DAYS_FOR_HERO_OF_THE_DAY": portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY,
                "page_type": "index",
            },
        )
开发者ID:Tiendil,项目名称:the-tale,代码行数:78,代码来源:views.py


注:本文中的the_tale.accounts.prototypes.AccountPrototype.live_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。