本文整理汇总了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])
示例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)
示例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)
示例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)
示例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)