return usage_per_version adus as list to preserve order (#21066)
* return usage_per_version adus as list to preserve order * prettier fix
This commit is contained in:
Родитель
58f3be9677
Коммит
fdc043d856
|
@ -8454,7 +8454,7 @@ class TestUsagePerVersion(ReviewerTest):
|
|||
|
||||
get_adu_per_version_mock.assert_called_once_with(self.addon)
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {}
|
||||
assert response.json() == {'adus': []}
|
||||
|
||||
@mock.patch(
|
||||
'olympia.reviewers.views.get_average_daily_users_per_version_from_bigquery'
|
||||
|
@ -8468,7 +8468,9 @@ class TestUsagePerVersion(ReviewerTest):
|
|||
response = self.client.get(self.url)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {'1.1': '394', '2': '450', '3.4545': '9,999'}
|
||||
assert response.json() == {
|
||||
'adus': [['1.1', '394'], ['2', '450'], ['3.4545', '9,999']]
|
||||
}
|
||||
|
||||
def test_not_reviewer(self):
|
||||
user_factory(email='irregular@mozilla.com')
|
||||
|
|
|
@ -1528,7 +1528,7 @@ class ReviewAddonVersionCompareViewSet(
|
|||
def usage_per_version(request, addon):
|
||||
versions_avg = get_average_daily_users_per_version_from_bigquery(addon)
|
||||
response = JsonResponse(
|
||||
{version: numberfmt(adu) for (version, adu) in versions_avg}
|
||||
{'adus': [[version, numberfmt(adu)] for (version, adu) in versions_avg]}
|
||||
)
|
||||
patch_cache_control(response, max_age=5 * 60)
|
||||
return response
|
||||
|
|
|
@ -544,9 +544,15 @@ function initVersionsADU() {
|
|||
function loadVersionsADU() {
|
||||
const aduUrl = $('#addon').data('versions-adu-url');
|
||||
$.get(aduUrl, function (data) {
|
||||
const versionAduPairs = Object.entries(data);
|
||||
fillVersionsTable(versionAduPairs);
|
||||
fillTopTenBox(versionAduPairs);
|
||||
const versionAduPairs = data.adus;
|
||||
if (versionAduPairs !== undefined) {
|
||||
fillVersionsTable(versionAduPairs);
|
||||
fillTopTenBox(versionAduPairs);
|
||||
} else {
|
||||
$('#version-adu-top-ten div').append(
|
||||
'No average daily user values because BigQuery disabled.',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
loadVersionsADU();
|
||||
|
|
Загрузка…
Ссылка в новой задаче