зеркало из https://github.com/mozilla/kitsune.git
Merge pull request #6057 from escattone/fix-weekly-pageview-crons-1819
fix article & question weekly pageview crons
This commit is contained in:
Коммит
9010c23620
|
@ -288,13 +288,16 @@ def pageviews_by_document(period, verbose=False):
|
|||
|
||||
for row in run_report(date_range, create_article_report_request, verbose=verbose):
|
||||
path = row.dimension_values[0].value
|
||||
num_page_views = int(row.metric_values[0].value)
|
||||
# The path is guaranteed to be a KB article path without any query parameters.
|
||||
# If the URL path for KB articles changes, we'll need to continue to support
|
||||
# the previous URL structure for a year -- the longest period of time we look
|
||||
# backwards -- as well as the new URL structure.
|
||||
# The path should be a KB article path without any query parameters, but in reality
|
||||
# we've seen that it can sometimes be "/". If the URL path for KB articles changes,
|
||||
# we'll need to continue to support the previous URL structure for a year -- the
|
||||
# longest period of time we look backwards -- as well as the new URL structure.
|
||||
# Current URL structure: /{locale}/kb/{slug}
|
||||
locale, slug = path.strip("/").split("/kb/")
|
||||
try:
|
||||
num_page_views = int(row.metric_values[0].value)
|
||||
locale, slug = path.strip("/").split("/kb/")
|
||||
except ValueError:
|
||||
continue
|
||||
yield ((locale, slug), num_page_views)
|
||||
|
||||
|
||||
|
@ -307,14 +310,18 @@ def pageviews_by_question(period=LAST_YEAR, verbose=False):
|
|||
|
||||
for row in run_report(date_range, create_question_report_request, verbose=verbose):
|
||||
path = row.dimension_values[0].value
|
||||
num_page_views = int(row.metric_values[0].value)
|
||||
# The path is guaranteed to be a question path without any query parameters.
|
||||
# If the URL path for questions changes, we'll need to continue to support
|
||||
# the previous URL structure for a year -- the longest period of time we look
|
||||
# backwards -- as well as the new URL structure.
|
||||
# The path should be a question path without any query parameters, but in reality
|
||||
# we've seen that it can sometimes be "/". If the URL path for questions changes,
|
||||
# we'll need to continue to support the previous URL structure for a year -- the
|
||||
# longest period of time we look backwards -- as well as the new URL structure.
|
||||
# Current URL structure: /{locale}/questions/{question_id}
|
||||
locale, question_id = path.strip("/").split("/questions/")
|
||||
yield (int(question_id), num_page_views)
|
||||
try:
|
||||
num_page_views = int(row.metric_values[0].value)
|
||||
locale, question_id = path.strip("/").split("/questions/")
|
||||
question_id = int(question_id)
|
||||
except ValueError:
|
||||
continue
|
||||
yield (question_id, num_page_views)
|
||||
|
||||
|
||||
def search_clicks_and_impressions(start_date, end_date, verbose=False):
|
||||
|
|
|
@ -72,6 +72,10 @@ class GoogleAnalyticsTests(TestCase):
|
|||
dimension_values=[DimensionValue(value="/en-US/kb/doc1-slug")],
|
||||
metric_values=[MetricValue(value="1000")],
|
||||
),
|
||||
Row(
|
||||
dimension_values=[DimensionValue(value="/")],
|
||||
metric_values=[MetricValue(value="7")],
|
||||
),
|
||||
Row(
|
||||
dimension_values=[DimensionValue(value="/es/kb/doc2-slug")],
|
||||
metric_values=[MetricValue(value="2000")],
|
||||
|
@ -97,6 +101,10 @@ class GoogleAnalyticsTests(TestCase):
|
|||
dimension_values=[DimensionValue(value="/en-US/questions/123456")],
|
||||
metric_values=[MetricValue(value="1000")],
|
||||
),
|
||||
Row(
|
||||
dimension_values=[DimensionValue(value="/")],
|
||||
metric_values=[MetricValue(value="7")],
|
||||
),
|
||||
Row(
|
||||
dimension_values=[DimensionValue(value="/es/questions/782348")],
|
||||
metric_values=[MetricValue(value="2000")],
|
||||
|
|
Загрузка…
Ссылка в новой задаче