本文整理汇总了Python中dashboards.models.WikiDocumentVisits.reload_period_from_json方法的典型用法代码示例。如果您正苦于以下问题:Python WikiDocumentVisits.reload_period_from_json方法的具体用法?Python WikiDocumentVisits.reload_period_from_json怎么用?Python WikiDocumentVisits.reload_period_from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dashboards.models.WikiDocumentVisits
的用法示例。
在下文中一共展示了WikiDocumentVisits.reload_period_from_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_pages
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import reload_period_from_json [as 别名]
def test_no_pages(self):
"""Don't pave over current data if WebTrends returns well-formatted
data structure with no interesting data in it."""
# Get some JSON that contains no interesting data.
no_pages = '{"data": {"12/01/2010-12/07/2010": {"SubRows": {}}}}'
counts = WikiDocumentVisits._visit_counts(no_pages)
eq_({}, counts) # Make sure nothing interesting is there.
# Try to reload visits table from the uninteresting data:
d = document()
d.save()
v = WikiDocumentVisits.objects.create(document=d, visits=12, period=THIS_WEEK)
WikiDocumentVisits.reload_period_from_json(THIS_WEEK, no_pages)
# Visits table should remain unchanged:
eq_(1, WikiDocumentVisits.objects.filter(pk=v.pk).count())
示例2: reload_wiki_traffic_stats
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import reload_period_from_json [as 别名]
def reload_wiki_traffic_stats():
transaction.enter_transaction_management()
transaction.managed(True)
for period, _ in PERIODS:
try:
WikiDocumentVisits.reload_period_from_json(
period, WikiDocumentVisits.json_for(period))
except:
transaction.rollback()
raise
else:
transaction.commit()
# Nice but not necessary when the process is about to exit:
transaction.leave_transaction_management()