• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.InappPayment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.inapp_pay.models.InappPayment的典型用法代码示例。如果您正苦于以下问题:Python InappPayment类的具体用法?Python InappPayment怎么用?Python InappPayment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: index_finance_total_inapp

def index_finance_total_inapp(addons, **kw):
    """
    Bug 758071
    Aggregates financial stats from all of the contributions for in-apps.
    """
    index = kw.get('index', InappPayment._get_index())
    es = amo.search.get_es()
    log.info('Indexing total financial in-app stats for %s apps.' %
             len(addons))

    for addon in addons:
        # Get all in-app names for given addon.
        inapps = set(InappPayment.objects.filter(config__addon=addon).
            values_list('name', flat=True))

        for inapp_name in inapps:
            # Get all in-app payments for given in-app.
            qs = InappPayment.objects.filter(name=inapp_name,
                                             contribution__uuid=None)
            if not qs.exists():
                continue

            try:
                key = ord_word('totinapp' + str(addon) + inapp_name)
                data = search.get_finance_total_inapp(qs, addon, inapp_name)
                for index in get_indices(index):
                    if not already_indexed(InappPayment, data, index):
                        InappPayment.index(data, bulk=True, id=key,
                                           index=index)
                es.flush_bulk(forced=True)
            except Exception, exc:
                index_finance_total_inapp.retry(args=[addons], exc=exc, **kw)
                raise
开发者ID:KryDos,项目名称:zamboni,代码行数:33,代码来源:tasks.py


示例2: test_index

    def test_index(self):
        tasks.index_finance_daily_inapp.delay(self.ids)
        self.refresh(timesleep=1)

        document = InappPayment.search().filter(config__addon=self.app.pk
            ).values_dict('date', 'inapp', 'revenue', 'count', 'refunds')[0]

        eq_(self.inapp_name, document['inapp'])

        date = document['date']
        ex_date = self.expected[self.inapp_name]['date']
        eq_((date.year, date.month, date.day),
            (ex_date.year, ex_date.month, ex_date.day))

        document = {
            self.inapp_name: {
                    'count': document['count'],
                    'revenue': int(document['revenue']),
                    'refunds': document['refunds']
            }
        }
        del(self.expected[self.inapp_name]['date'])

        self.expected[self.inapp_name]['revenue'] = (
            int(self.expected[self.inapp_name]['revenue']))
        eq_(document, self.expected)
开发者ID:MaxDumont,项目名称:zamboni,代码行数:26,代码来源:test_tasks.py


示例3: test_index

    def test_index(self):
        tasks.index_finance_daily_inapp.delay(self.ids)
        self.refresh(timesleep=1)

        document = (
            InappPayment.search()
            .filter(config__addon=self.app.pk)
            .values_dict("date", "inapp", "revenue", "count", "refunds")[0]
        )

        eq_(self.inapp_name, document["inapp"])

        date = document["date"]
        ex_date = self.expected[self.inapp_name]["date"]
        eq_((date.year, date.month, date.day), (ex_date.year, ex_date.month, ex_date.day))

        document = {
            self.inapp_name: {
                "count": document["count"],
                "revenue": int(document["revenue"]),
                "refunds": document["refunds"],
            }
        }
        del (self.expected[self.inapp_name]["date"])

        self.expected[self.inapp_name]["revenue"] = int(self.expected[self.inapp_name]["revenue"])
        eq_(document, self.expected)
开发者ID:rhelmer,项目名称:zamboni,代码行数:27,代码来源:test_tasks.py


示例4: index_finance_total_inapp_by_src

def index_finance_total_inapp_by_src(addons, **kw):
    """
    Total finance in-app stats, src breakdown.
    """
    index = kw.get('index', InappPayment._get_index())
    es = amo.search.get_es()
    log.info('Indexing total financial in-app stats by src for %s apps.' %
             len(addons))

    for addon in addons:
        # Get all in-app names for given addon.
        inapps = set(InappPayment.objects.filter(config__addon=addon).
            values_list('name', flat=True))

        for inapp_name in inapps:
            # Get all in-app payments for given in-app.
            qs = InappPayment.objects.filter(name=inapp_name,
                                             contribution__uuid=None)
            if not qs.exists():
                continue
            # Get a list of distinct sources for given in-app.
            sources = set(qs.values_list('contribution__source',
                flat=True))

            for source in sources:
                try:
                    key = ord_word('srcinapp' + str(addon) + inapp_name +
                                   source.lower())
                    try:
                        data = search.get_finance_total_inapp(
                            qs, addon, inapp_name, 'source', source=source)

                        for index in get_indices(index):
                            if not already_indexed(InappPayment, data, index):
                                InappPayment.index(data, bulk=True, id=key,
                                                   index=index)
                    except Exception, e:
                        # We ignore this error for now. See #805181
                        pass

                    es.flush_bulk(forced=True)

                except Exception, exc:
                    index_finance_total_by_src.retry(args=[addons],
                                                     exc=exc, **kw)
                    raise
开发者ID:KryDos,项目名称:zamboni,代码行数:46,代码来源:tasks.py


示例5: index_finance_total_inapp_by_currency

def index_finance_total_inapp_by_currency(addons, **kw):
    """
    Bug 758071
    Total finance in-app stats, currency breakdown.
    """
    index = kw.get('index', InappPayment._get_index())
    es = amo.search.get_es()
    log.info('Indexing total financial in-app stats by currency for %s apps.' %
             len(addons))

    for addon in addons:
        # Get all in-app names for given addon.
        inapps = set(InappPayment.objects.filter(config__addon=addon).
            values_list('name', flat=True))

        for inapp_name in inapps:
            # Get all in-app payments for given in-app.
            qs = InappPayment.objects.filter(name=inapp_name,
                                             contribution__uuid=None)
            if not qs.exists():
                continue
            # Get a list of distinct currencies for given in-app.
            currencies = set(qs.values_list('contribution__currency',
                flat=True))

            for currency in currencies:
                try:
                    key = ord_word('curinapp' + str(addon) + inapp_name +
                                   currency.lower())
                    data = search.get_finance_total_inapp(
                        qs, addon, inapp_name, 'currency', currency=currency)
                    for index in get_indices(index):
                        if not already_indexed(InappPayment, data, index):
                            InappPayment.index(data, bulk=True, id=key,
                                               index=index)
                    es.flush_bulk(forced=True)
                except Exception, exc:
                    index_finance_total_by_currency.retry(args=[addons],
                                                          exc=exc, **kw)
                    raise
开发者ID:KryDos,项目名称:zamboni,代码行数:40,代码来源:tasks.py


示例6: index_finance_daily_inapp

def index_finance_daily_inapp(ids, **kw):
    """
    Similar to index_finance_daily, except for InappPayments.

    ids -- ids of mkt.stats.webapps.InappPayment objects
    """
    index = kw.get('index', InappPayment._get_index())
    es = amo.search.get_es()

    # Get contributions.
    qs = (InappPayment.objects.filter(id__in=ids)
          .order_by('created').values('name',
                                      'config__addon',
                                      'created'))
    log.info('[%s] Indexing %s in-app payments for daily stats.' %
             (qs[0]['created'], len(ids)))

    # It's defaultdicts all the way down.
    addons_inapps_dates = defaultdict(lambda: defaultdict(
        lambda: defaultdict(int)))
    for payment in qs:
        addon = payment['config__addon']
        inapp = payment['name']
        date = payment['created'].strftime('%Y%m%d')

        # Date for add-on not processed, index it and give it key.
        if not date in addons_inapps_dates[addon][inapp]:
            key = ord_word('fin%s%s%s' % (str(addon), str(inapp), str(date)))
            data = search.get_finance_daily_inapp(payment)
            try:
                if not already_indexed(InappPayment, data, index):
                    InappPayment.index(data, bulk=True, id=key, index=index)
                addons_inapps_dates[addon][inapp][date] = 0
                es.flush_bulk(forced=True)
            except Exception, exc:
                index_finance_daily_inapp.retry(args=[ids], exc=exc, **kw)
                raise
开发者ID:KryDos,项目名称:zamboni,代码行数:37,代码来源:tasks.py


示例7: stats_report

def stats_report(request, addon, report, inapp=None, category_field=None):
    """
    Stats page. Passes in context variables into template which is read by the
    JS to build a URL. The URL calls a *_series view which determines
    necessary arguments for get_series_*. get_series_* queries ES for the data,
    which is later formatted into .json or .csv and made available to the JS.
    """
    if addon.status is not amo.STATUS_PUBLIC and not check_stats_permission(
        request, addon, for_contributions=True, no_raise=True
    ):
        return redirect(addon.get_detail_url())
    check_stats_permission(request, addon)

    # For inapp, point template to same as non-inapp, but still use
    # different report names.
    template_name = "appstats/reports/%s.html" % report.replace("_inapp", "")
    if inapp:
        stats_base_url = addon.get_stats_inapp_url(action="revenue", inapp=inapp)
    else:
        stats_base_url = reverse("mkt.stats.overview", args=[addon.app_slug])
    view = get_report_view(request)

    # Get list of in-apps for drop-down in-app selector.
    inapps = []
    # Until we figure out why ES stores strings in lowercase despite
    # the field being set to not analyze, we grab the lowercase version
    # from ES and do a case-insensitive query to the ORM to un-lowercase.
    inapps_lower = list(
        set(payment["inapp"] for payment in list(InappPayment.search().filter(addon=addon.id).values_dict("inapp")))
    )
    for inapp_name in inapps_lower:
        inapps.append(InappPayment.objects.filter(name__iexact=inapp_name)[0].name)

    return jingo.render(
        request,
        template_name,
        {
            "addon": addon,
            "report": report,
            "view": view,
            "stats_base_url": stats_base_url,
            "inapp": inapp,
            "inapps": inapps,
        },
    )
开发者ID:rtnpro,项目名称:zamboni,代码行数:45,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.LangPack类代码示例发布时间:2022-05-27
下一篇:
Python models.InappConfig类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap