def reload_wiki_traffic_stats(): if settings.STAGE: return for period, _ in PERIODS: WikiDocumentVisits.reload_period_from_analytics( period, verbose=settings.DEBUG)
def reload_wiki_traffic_stats(): if settings.STAGE: print ('Skipped reload_wiki_traffic_stats(). ' 'Set settings.STAGE to False to run it for real.') return for period, _ in PERIODS: WikiDocumentVisits.reload_period_from_analytics(period)
def reload_wiki_traffic_stats(): if settings.STAGE: print('Skipped reload_wiki_traffic_stats(). ' 'Set settings.STAGE to False to run it for real.') return for period, _ in PERIODS: WikiDocumentVisits.reload_period_from_analytics(period)
def test_visit_count_from_analytics(self, _build_request, close_old_connections): """Verify stored visit counts from mocked analytics data. It has some nasty non-ASCII chars in it. """ execute = _build_request.return_value.get.return_value.execute execute.return_value = PAGEVIEWS_BY_DOCUMENT_RESPONSE d1 = ApprovedRevisionFactory(document__slug="hellỗ").document d2 = ApprovedRevisionFactory(document__slug="there").document WikiDocumentVisits.reload_period_from_analytics(LAST_7_DAYS) eq_(2, WikiDocumentVisits.objects.count()) wdv1 = WikiDocumentVisits.objects.get(document=d1) eq_(27, wdv1.visits) eq_(LAST_7_DAYS, wdv1.period) wdv2 = WikiDocumentVisits.objects.get(document=d2) eq_(LAST_7_DAYS, wdv2.period)
def test_visit_count_from_analytics(self, _build_request, close_old_connections): """Verify stored visit counts from mocked analytics data. It has some nasty non-ASCII chars in it. """ execute = _build_request.return_value.get.return_value.execute execute.return_value = PAGEVIEWS_BY_DOCUMENT_RESPONSE d1 = ApprovedRevisionFactory(document__slug=u'hellỗ').document d2 = ApprovedRevisionFactory(document__slug=u'there').document WikiDocumentVisits.reload_period_from_analytics(LAST_7_DAYS) eq_(2, WikiDocumentVisits.objects.count()) wdv1 = WikiDocumentVisits.objects.get(document=d1) eq_(27, wdv1.visits) eq_(LAST_7_DAYS, wdv1.period) wdv2 = WikiDocumentVisits.objects.get(document=d2) eq_(LAST_7_DAYS, wdv2.period)
def test_visit_count_from_analytics(self, _build_request): """Verify stored visit counts from mocked analytics data. It has some nasty non-ASCII chars in it. """ execute = _build_request.return_value.get.return_value.execute execute.return_value = PAGEVIEWS_BY_DOCUMENT_RESPONSE d1 = revision(document=document(slug='hellỗ', save=True), is_approved=True, save=True).document d2 = revision(document=document(slug='there', save=True), is_approved=True, save=True).document WikiDocumentVisits.reload_period_from_analytics(LAST_7_DAYS) eq_(2, WikiDocumentVisits.objects.count()) wdv1 = WikiDocumentVisits.objects.get(document=d1) eq_(27, wdv1.visits) eq_(LAST_7_DAYS, wdv1.period) wdv2 = WikiDocumentVisits.objects.get(document=d2) eq_(LAST_7_DAYS, wdv2.period)
def handle(self, **options): for period, _ in PERIODS: WikiDocumentVisits.reload_period_from_analytics( period, verbose=settings.DEBUG)