Milimetric has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275681
Change subject: Strip out www. in front of project names
......................................................................
Strip out www. in front of project names
Bug: T127030
Change-Id: I49410c88632068d975ed1fd91d2ecb9c0726232f
---
M sys/pageviews.js
M test/features/pageviews/pageviews.js
M v1/pageviews.yaml
3 files changed, 19 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/aqs
refs/changes/81/275681/1
diff --git a/sys/pageviews.js b/sys/pageviews.js
index cbaaaf7..debcb9b 100644
--- a/sys/pageviews.js
+++ b/sys/pageviews.js
@@ -170,9 +170,10 @@
/**
* Cleans the project parameter so it can be passed in as either
en.wikipedia.org or en.wikipedia
+ * Also cleans any www. prefix so that projects like www.mediawiki.org or
www.wikidata.org work
*/
-var stripOrgFromProject = function(rp) {
- rp.project = rp.project.replace(/\.org$/, '');
+var stripProject = function(rp) {
+ rp.project = rp.project.replace(/www\./, '').replace(/\.org$/, '');
};
@@ -211,7 +212,7 @@
'invalid, must be a valid date in YYYYMMDD format' :
'invalid, must be a valid timestamp in YYYYMMDDHH format';
- stripOrgFromProject(rp);
+ stripProject(rp);
if (!validateTimestamp(rp.start, opts)) {
errors.push('start timestamp is ' + invalidMessage);
@@ -230,7 +231,7 @@
var validateYearMonthDay = function(rp) {
var errors = [];
- stripOrgFromProject(rp);
+ stripProject(rp);
if (rp.month === 'all-months' && rp.day !== 'all-days') {
errors.push('day must be "all-days" when passing "all-months"');
diff --git a/test/features/pageviews/pageviews.js
b/test/features/pageviews/pageviews.js
index 222b590..5fcd4d7 100644
--- a/test/features/pageviews/pageviews.js
+++ b/test/features/pageviews/pageviews.js
@@ -18,6 +18,7 @@
// 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 projectEndpoint =
'/pageviews/aggregate/en.wikipedia/all-access/all-agents/hourly/1969010100/1971010100';
+ var projectEndpointStrip =
'/pageviews/aggregate/www.en.wikipedia.org/all-access/all-agents/hourly/1969010100/1971010100';
var topsEndpoint =
'/pageviews/top/en.wikipedia/mobile-web/2015/all-months/all-days';
// Fake data insertion endpoints
@@ -120,6 +121,16 @@
});
});
+ it('should return the expected aggregate data after insertion, when
querying with www.<<project>>.org', function () {
+ // data for this is already inserted in the test above, weird that
tests are inter-dependent
+ return preq.get({
+ uri: server.config.aqsURL + projectEndpointStrip
+ }).then(function(res) {
+ assert.deepEqual(res.body.items.length, 1);
+ assert.deepEqual(res.body.items[0].views, 0);
+ });
+ });
+
it('should return the expected aggregate data after long insertion',
function () {
return preq.post({
uri: server.config.aqsURL +
diff --git a/v1/pageviews.yaml b/v1/pageviews.yaml
index 5b08010..ec70037 100644
--- a/v1/pageviews.yaml
+++ b/v1/pageviews.yaml
@@ -44,7 +44,7 @@
parameters:
- name: project
in: path
- description: The name of any Wikimedia project formatted like
{language code}.{project name}, for example en.wikipedia. You may pass
en.wikipedia.org and the .org will be stripped off. For projects like commons
without language codes, use commons.wikimedia
+ description: The name of any Wikimedia project formatted like
{language code}.{project name}, for example en.wikipedia. You may pass
en.wikipedia.org and the .org will be stripped off. For projects like commons
without language codes, use commons.wikimedia. For projects like
www.mediawiki.org, you can use that full string, or just use mediawiki or
mediawiki.org.
type: string
required: true
- name: access
@@ -107,7 +107,7 @@
parameters:
- name: project
in: path
- description: If you want to filter by project, use the name of any
Wikimedia project formatted like {language code}.{project name}, for example
en.wikipedia. You may pass en.wikipedia.org and the .org will be stripped off.
For projects like commons without language codes, use commons.wikimedia. If you
are interested in all pageviews regardless of project, use all-projects
+ description: If you want to filter by project, use the name of any
Wikimedia project formatted like {language code}.{project name}, for example
en.wikipedia. You may pass en.wikipedia.org and the .org will be stripped off.
For projects like commons without language codes, use commons.wikimedia. For
projects like www.mediawiki.org, you can use that full string, or just use
mediawiki or mediawiki.org. If you are interested in all pageviews regardless
of project, use all-projects.
type: string
required: true
- name: access
@@ -188,7 +188,7 @@
parameters:
- name: project
in: path
- description: The name of any Wikimedia project formatted like
{language code}.{project name}, for example en.wikipedia. You may pass
en.wikipedia.org and the .org will be stripped off. For projects like commons
without language codes, use commons.wikimedia
+ description: The name of any Wikimedia project formatted like
{language code}.{project name}, for example en.wikipedia. You may pass
en.wikipedia.org and the .org will be stripped off. For projects like commons
without language codes, use commons.wikimedia. For projects like
www.mediawiki.org, you can use that full string, or just use mediawiki or
mediawiki.org.
type: string
required: true
- name: access
--
To view, visit https://gerrit.wikimedia.org/r/275681
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I49410c88632068d975ed1fd91d2ecb9c0726232f
Gerrit-PatchSet: 1
Gerrit-Project: analytics/aqs
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits