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


Python Contribution.search方法代码示例

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


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

示例1: test_index

# 需要导入模块: from stats.models import Contribution [as 别名]
# 或者: from stats.models.Contribution import search [as 别名]
    def test_index(self):
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
        raise SkipTest('Test is unreliable and causes intermittent failures.')

        # Grab document for each source breakdown and compare.
        for currency in self.currencies:
            # For some reason, query fails if uppercase letter in filter.
            document = (Contribution.search().filter(addon=self.app.pk,
                        currency=currency.lower()).values_dict('currency',
                        'revenue', 'count', 'refunds',
                        'revenue_non_normalized')[0])
            document = {
                'count': document['count'],
                'revenue': int(document['revenue']),
                'refunds': document['refunds'],
                'revenue_non_normalized':
                    int(document['revenue_non_normalized'])}
            self.expected[currency]['revenue'] = (
                int(self.expected[currency]['revenue'])
            )
            self.expected[currency]['revenue_non_normalized'] = (
                int(self.expected[currency]['revenue_non_normalized'])
            )
            eq_(document, self.expected[currency])
开发者ID:chenliu0831,项目名称:zamboni,代码行数:27,代码来源:test_tasks.py

示例2: test_index

# 需要导入模块: from stats.models import Contribution [as 别名]
# 或者: from stats.models.Contribution import search [as 别名]
    def test_index(self):
        tasks.index_finance_total([self.app.pk])
        self.refresh(timesleep=1)

        document = Contribution.search().filter(addon=self.app.pk).values_dict("revenue", "count", "refunds")[0]

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

        eq_(document, self.expected)
开发者ID:rhelmer,项目名称:zamboni,代码行数:12,代码来源:test_tasks.py

示例3: index_latest_mkt_stats

# 需要导入模块: from stats.models import Contribution [as 别名]
# 或者: from stats.models.Contribution import search [as 别名]
def index_latest_mkt_stats():
    latest_contribution = Contribution.search().order_by('-date'
        ).values_dict()[0]['date']
    latest_install = Installed.search().order_by('-date'
        ).values_dict()[0]['date']

    latest = min(latest_contribution, latest_install)

    fmt = lambda d: d.strftime('%Y-%m-%d')
    date_range = '%s:%s' % (fmt(latest), fmt(datetime.date.today()))
    cron_log.info('index_mkt_stats --date=%s' % date_range)
    call_command('index_mkt_stats', addons=None, date=date_range)
开发者ID:Sancus,项目名称:zamboni,代码行数:14,代码来源:cron.py

示例4: test_index

# 需要导入模块: from stats.models import Contribution [as 别名]
# 或者: from stats.models.Contribution import search [as 别名]
    def test_index(self):
        tasks.index_finance_total([self.app.pk])
        self.refresh(timesleep=1)

        document = Contribution.search().filter(addon=self.app.pk
            ).values_dict('revenue', 'count', 'refunds')[0]

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

        eq_(document, self.expected)
开发者ID:MaxDumont,项目名称:zamboni,代码行数:15,代码来源:test_tasks.py

示例5: index_latest_mkt_stats

# 需要导入模块: from stats.models import Contribution [as 别名]
# 或者: from stats.models.Contribution import search [as 别名]
def index_latest_mkt_stats(index=None, aliased=True):
    raise_if_reindex_in_progress()
    yesterday = datetime.date.today() - datetime.timedelta(days=1)

    try:
        latest = Contribution.search(index).order_by('-date').values_dict()
        latest_contribution = latest and latest[0]['date'] or yesterday
    except pyes.exceptions.SearchPhaseExecutionException:
        latest_contribution = yesterday

    try:
        latest = Installed.search(index).order_by('-date').values_dict()
        latest_install = latest and latest[0]['date'] or yesterday
    except pyes.exceptions.SearchPhaseExecutionException:
        latest_install = yesterday

    latest = min(latest_contribution, latest_install)

    fmt = lambda d: d.strftime('%Y-%m-%d')
    date_range = '%s:%s' % (fmt(latest), fmt(datetime.date.today()))
    cron_log.info('index_mkt_stats --date=%s' % date_range)
    call_command('index_mkt_stats', addons=None, date=date_range, index=index,
                 aliased=True)
开发者ID:KryDos,项目名称:zamboni,代码行数:25,代码来源:cron.py


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