Elukey has uploaded a new change for review. https://gerrit.wikimedia.org/r/315284
Change subject: Map null values to zeros in output in per-article endpoint ...................................................................... Map null values to zeros in output in per-article endpoint View counts for an article that are equal to 0 in any of the dimensions are being stored as 'null' in cassandra, aqs code should do the translation from one to the other. Bug: T144521 Change-Id: Idf1c517605714c3cf1cfad044d3e8763cc0f2ece --- M sys/pageviews.js M test/aqs_test_module.yaml M test/features/pageviews/pageviews.js 3 files changed, 15 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/aqs refs/changes/84/315284/1 diff --git a/sys/pageviews.js b/sys/pageviews.js index a203e41..9c37a4a 100644 --- a/sys/pageviews.js +++ b/sys/pageviews.js @@ -165,6 +165,10 @@ item.access = rp.access; item.agent = rp.agent; item.views = item[viewKey(rp.access, rp.agent)]; + // map null to zero for view counts, we store null in cassandra for efficiency + if (item.views === null) { + item.views = 0; + } removeDenormalizedColumns(item); }); } diff --git a/test/aqs_test_module.yaml b/test/aqs_test_module.yaml index fa93af9..f5f9af7 100644 --- a/test/aqs_test_module.yaml +++ b/test/aqs_test_module.yaml @@ -30,7 +30,7 @@ da: '{{request.params.views}}5' db: '{{request.params.views}}6' ds: '{{request.params.views}}7' - du: '{{request.params.views}}8' + du: null maa: '{{request.params.views}}9' mab: '{{request.params.views}}10' mas: '{{request.params.views}}11' diff --git a/test/features/pageviews/pageviews.js b/test/features/pageviews/pageviews.js index ea5f20b..72a1f7f 100644 --- a/test/features/pageviews/pageviews.js +++ b/test/features/pageviews/pageviews.js @@ -15,6 +15,7 @@ // NOTE: this tests using the projects/aqs_default.yaml config, so // it doesn't know about the /metrics root like the prod config does var articleEndpoint = '/pageviews/per-article/en.wikipedia/desktop/spider/one/daily/20150701/20150703'; + var articleEndpointMobile = '/pageviews/per-article/en.wikipedia/desktop/user/one/daily/20150701/20150703'; var projectEndpoint = '/pageviews/aggregate/en.wikipedia/all-access/all-agents/hourly/1969010100/1971010100'; var topsEndpoint = '/pageviews/top/en.wikipedia/mobile-web/2015/01/all-days'; var projectEndpointStrip = '/pageviews/aggregate/www.en.wikipedia.org/all-access/all-agents/hourly/1969010100/1971010100'; @@ -71,6 +72,15 @@ }); }); + it('should return integer zero if view count is null', function () { + return preq.get({ + uri: server.config.aqsURL + articleEndpointMobile + + }).then(function (res) { + assert.deepEqual(res.body.items.length, 1); + assert.deepEqual(res.body.items[0].views, 0); + }); + }); function r(s, replaceSpaces) { var weirdArticleTitle = 'dash - space : colon % percent / slash'; -- To view, visit https://gerrit.wikimedia.org/r/315284 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf1c517605714c3cf1cfad044d3e8763cc0f2ece Gerrit-PatchSet: 1 Gerrit-Project: analytics/aqs Gerrit-Branch: master Gerrit-Owner: Elukey <ltosc...@wikimedia.org> Gerrit-Reviewer: Nuria <nu...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits