Fdans has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/339419 )
Change subject: Format timestamps in per-project aggregation so that comparison in Cassandra returns the correct months ...................................................................... Format timestamps in per-project aggregation so that comparison in Cassandra returns the correct months Bug: T156312 Change-Id: I55e039bc1f18832724ea9683d8c841a18bd992f5 --- M sys/pageviews.js M test/features/pageviews/pageviews.js 2 files changed, 30 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/aqs refs/changes/19/339419/1 diff --git a/sys/pageviews.js b/sys/pageviews.js index a3ba71e..02bb74c 100644 --- a/sys/pageviews.js +++ b/sys/pageviews.js @@ -219,7 +219,11 @@ PJVS.prototype.pageviewsForProjects = function(hyper, req) { var rp = req.params; - aqsUtil.validateStartAndEnd(rp); + aqsUtil.validateStartAndEnd(rp, { + fakeHour: true, + zeroHour: true, + fullMonths: rp.granularity === MONTHLY + }); var dataRequest = hyper.get({ uri: tableURI(rp.domain, tables.project), diff --git a/test/features/pageviews/pageviews.js b/test/features/pageviews/pageviews.js index 9d1bf60..3c61e52 100644 --- a/test/features/pageviews/pageviews.js +++ b/test/features/pageviews/pageviews.js @@ -18,12 +18,14 @@ var articleEndpointMobile = '/pageviews/per-article/en.wikipedia/desktop/user/one/daily/20150701/20150703'; var articleEndpointMonthly = '/pageviews/per-article/en.wikipedia/desktop/spider/one/monthly/20150601/20150803'; var projectEndpoint = '/pageviews/aggregate/en.wikipedia/all-access/all-agents/hourly/1969010100/1971010100'; + var projectEndpointMonthly = '/pageviews/aggregate/en.wikipedia/all-access/all-agents/monthly/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'; // Fake data insertion endpoints var insertArticleEndpoint = '/pageviews/insert-per-article-flat/en.wikipedia/one/daily/2015070200'; var insertProjectEndpoint = '/pageviews/insert-aggregate/en.wikipedia/all-access/all-agents/hourly/1970010100'; + var insertProjectEndpointMonthly = '/pageviews/insert-aggregate/en.wikipedia/all-access/all-agents/monthly/1970010100'; var insertProjectEndpointLong = '/pageviews/insert-aggregate-long/en.wikipedia/all-access/all-agents/hourly/1970010100'; var insertTopsEndpoint = '/pageviews/insert-top/en.wikipedia/mobile-web/2015/01/all-days'; @@ -201,6 +203,29 @@ }); }); + // This will only make a difference while testing in Cassandra + it('should return whole months between two dates', function (done) { + var datesToAdd = 3; + ['2016020100', '2016030100', '2016040100'].forEach(function (timestamp) { + preq.post({ + uri: server.config.aqsURL + insertProjectEndpointMonthly + .replace('1970010100', timestamp) + '/100' + }).then(function (res) { + datesToAdd--; + if (datesToAdd === 0) { + preq.get({ + uri: server.config.aqsURL + projectEndpointMonthly + .replace('1969010100', '2016020100') + .replace('1971010100', '2016040100') + }).then(function (res) { + assert.deepEqual(res.body.items[0].timestamp, 2016020100); + done(); + }); + } + }); + }); + }); + // WARNING: the data created in this test is used exactly as created // by the monitoring tests. it('should return the expected aggregate data after insertion', function() { -- To view, visit https://gerrit.wikimedia.org/r/339419 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I55e039bc1f18832724ea9683d8c841a18bd992f5 Gerrit-PatchSet: 1 Gerrit-Project: analytics/aqs Gerrit-Branch: master Gerrit-Owner: Fdans <fd...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits