[MediaWiki-commits] [Gerrit] Reorder getData params from datasets api - change (analytics/dashiki)
Milimetric has submitted this change and it was merged. Change subject: Reorder getData params from datasets api .. Reorder getData params from datasets api Reorders the parameters in getData method from datasets api, so that it matches the parameters in getData method from the wikimetrics api. Thus, both apis can be used interchangeably. Bug: T107504 Change-Id: If5aa1240f8c7b6751fbd1e76dcaaf22693fdd948 --- M src/app/apis/datasets-api.js M src/app/ko-extensions/async-observables.js M src/components/compare-layout/compare-layout.js M test/app/apis.js 4 files changed, 21 insertions(+), 9 deletions(-) Approvals: Milimetric: Verified; Looks good to me, approved diff --git a/src/app/apis/datasets-api.js b/src/app/apis/datasets-api.js index 16c79a7..99b3be6 100644 --- a/src/app/apis/datasets-api.js +++ b/src/app/apis/datasets-api.js @@ -27,11 +27,11 @@ * submetric : subcategory being measured * project : database name (enwiki, wikidata, etc.) */ -DatasetsApi.prototype.getData = function (metric, submetric, project) { +DatasetsApi.prototype.getData = function (metricInfo, project) { var deferred = new $.Deferred(), address = this.root + uri.expand('/{metric}/{submetric}/{project}.{format}', { -metric: metric, -submetric: submetric, +metric: metricInfo.metric, +submetric: metricInfo.submetric, project: project, format: this.config.format, }).toString(), @@ -41,7 +41,7 @@ url: address }).done(function (data) { var opt = { -label: submetric, +label: metricInfo.submetric, varyColors: true, }; diff --git a/src/app/ko-extensions/async-observables.js b/src/app/ko-extensions/async-observables.js index 1f57fac..e8baa01 100644 --- a/src/app/ko-extensions/async-observables.js +++ b/src/app/ko-extensions/async-observables.js @@ -14,7 +14,7 @@ * Does not care whether A or B is shown, only cares about observing * changes that would affect data */ -asyncData: function(api, metric, comparable, constantWiki) { +asyncData: function(api, metricInfo, constantWiki) { var result = ko.observable(new TimeseriesData([])); ko.computed(function () { @@ -22,7 +22,7 @@ from = ko.unwrap(this.fromDate.selected), to = ko.unwrap(this.toDate.selected); -api.getData(metric, comparable, wiki).done(function(data) { +api.getData(metricInfo, wiki).done(function(data) { result(data.filter(from, to)); }); diff --git a/src/components/compare-layout/compare-layout.js b/src/components/compare-layout/compare-layout.js index ba4dfa2..930ba3c 100644 --- a/src/components/compare-layout/compare-layout.js +++ b/src/components/compare-layout/compare-layout.js @@ -124,9 +124,13 @@ showAB = ko.unwrap(this.showAB); return ['a', 'b'].map(function (side) { +var metricInfo = { +'metric': c.metric, +'submetric': config[side] +}; return { promise: showAB[side] ? - api.getData(c.metric, config[side], wiki) + api.getData(metricInfo, wiki) : emptyPromise, label: config[side] }; @@ -170,8 +174,12 @@ c.desc = c.desc ? marked(c.desc, {sanitize: true}) : ''; if (c.annotationsMetric) { +var metricInfo = { +'metric': c.annotationsMetric, +'submetric': config.a +}; // use 'all' as the constant wiki, annotations don't vary by wiki -c.annotations = asyncData(api, c.annotationsMetric, config.a, 'all'); +c.annotations = asyncData(api, metricInfo, 'all'); } // default to a 10-color scale, but use config if present diff --git a/test/app/apis.js b/test/app/apis.js index 185fbc1..0ec9e32 100644 --- a/test/app/apis.js +++ b/test/app/apis.js @@ -289,7 +289,11 @@ datasetsApi.root = 'something'; var expected = 'something/metric/submetric/project.tsv'; -datasetsApi.getData('metric', 'submetric', 'project'); +var metricInfo = { +'metric': 'metric', +'submetric': 'submetric' +}; +
[MediaWiki-commits] [Gerrit] Reorder getData params from datasets api - change (analytics/dashiki)
Mforns has uploaded a new change for review. https://gerrit.wikimedia.org/r/234797 Change subject: Reorder getData params from datasets api .. Reorder getData params from datasets api Reorders the parameters in getData method from datasets api, so that it matches the parameters in getData method from the wikimetrics api. Thus, both apis can be used interchangeably. Bug: T107504 Change-Id: If5aa1240f8c7b6751fbd1e76dcaaf22693fdd948 --- M src/app/apis/datasets-api.js M src/app/ko-extensions/async-observables.js M src/components/compare-layout/compare-layout.js M test/app/apis.js 4 files changed, 21 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/dashiki refs/changes/97/234797/1 diff --git a/src/app/apis/datasets-api.js b/src/app/apis/datasets-api.js index 16c79a7..99b3be6 100644 --- a/src/app/apis/datasets-api.js +++ b/src/app/apis/datasets-api.js @@ -27,11 +27,11 @@ * submetric : subcategory being measured * project : database name (enwiki, wikidata, etc.) */ -DatasetsApi.prototype.getData = function (metric, submetric, project) { +DatasetsApi.prototype.getData = function (metricInfo, project) { var deferred = new $.Deferred(), address = this.root + uri.expand('/{metric}/{submetric}/{project}.{format}', { -metric: metric, -submetric: submetric, +metric: metricInfo.metric, +submetric: metricInfo.submetric, project: project, format: this.config.format, }).toString(), @@ -41,7 +41,7 @@ url: address }).done(function (data) { var opt = { -label: submetric, +label: metricInfo.submetric, varyColors: true, }; diff --git a/src/app/ko-extensions/async-observables.js b/src/app/ko-extensions/async-observables.js index 1f57fac..e8baa01 100644 --- a/src/app/ko-extensions/async-observables.js +++ b/src/app/ko-extensions/async-observables.js @@ -14,7 +14,7 @@ * Does not care whether A or B is shown, only cares about observing * changes that would affect data */ -asyncData: function(api, metric, comparable, constantWiki) { +asyncData: function(api, metricInfo, constantWiki) { var result = ko.observable(new TimeseriesData([])); ko.computed(function () { @@ -22,7 +22,7 @@ from = ko.unwrap(this.fromDate.selected), to = ko.unwrap(this.toDate.selected); -api.getData(metric, comparable, wiki).done(function(data) { +api.getData(metricInfo, wiki).done(function(data) { result(data.filter(from, to)); }); diff --git a/src/components/compare-layout/compare-layout.js b/src/components/compare-layout/compare-layout.js index ba4dfa2..930ba3c 100644 --- a/src/components/compare-layout/compare-layout.js +++ b/src/components/compare-layout/compare-layout.js @@ -124,9 +124,13 @@ showAB = ko.unwrap(this.showAB); return ['a', 'b'].map(function (side) { +var metricInfo = { +'metric': c.metric, +'submetric': config[side] +}; return { promise: showAB[side] ? - api.getData(c.metric, config[side], wiki) + api.getData(metricInfo, wiki) : emptyPromise, label: config[side] }; @@ -170,8 +174,12 @@ c.desc = c.desc ? marked(c.desc, {sanitize: true}) : ''; if (c.annotationsMetric) { +var metricInfo = { +'metric': c.annotationsMetric, +'submetric': config.a +}; // use 'all' as the constant wiki, annotations don't vary by wiki -c.annotations = asyncData(api, c.annotationsMetric, config.a, 'all'); +c.annotations = asyncData(api, metricInfo, 'all'); } // default to a 10-color scale, but use config if present diff --git a/test/app/apis.js b/test/app/apis.js index 185fbc1..0ec9e32 100644 --- a/test/app/apis.js +++ b/test/app/apis.js @@ -289,7 +289,11 @@ datasetsApi.root = 'something'; var expected = 'something/metric/submetric/project.tsv'; -datasetsApi.getData('metric', 'submetric', 'project'); +var metricInfo = { +'metric': 'metric', +