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


Python InappPayment.search方法代码示例

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


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

示例1: test_index

# 需要导入模块: from mkt.inapp_pay.models import InappPayment [as 别名]
# 或者: from mkt.inapp_pay.models.InappPayment import search [as 别名]
    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,代码行数:29,代码来源:test_tasks.py

示例2: test_index

# 需要导入模块: from mkt.inapp_pay.models import InappPayment [as 别名]
# 或者: from mkt.inapp_pay.models.InappPayment import search [as 别名]
    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,代码行数:28,代码来源:test_tasks.py

示例3: stats_report

# 需要导入模块: from mkt.inapp_pay.models import InappPayment [as 别名]
# 或者: from mkt.inapp_pay.models.InappPayment import search [as 别名]
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,代码行数:47,代码来源:views.py


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