示例#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
    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)