예제 #1
0
def reload_wiki_traffic_stats():
    if settings.STAGE:
        return

    for period, _ in PERIODS:
        WikiDocumentVisits.reload_period_from_analytics(
            period, verbose=settings.DEBUG)
예제 #2
0
def reload_wiki_traffic_stats():
    if settings.STAGE:
        return

    for period, _ in PERIODS:
        WikiDocumentVisits.reload_period_from_analytics(
            period, verbose=settings.DEBUG)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
파일: test_models.py 프로젝트: zu83/kitsune
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
 def handle(self, **options):
     for period, _ in PERIODS:
         WikiDocumentVisits.reload_period_from_analytics(
             period, verbose=settings.DEBUG)