Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor following RESTful API standards fix(#22, #23, #26) #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dashboard/core/bots/reports/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dashboard.core.tests.serializers import TestListListSerializer


class TestPathListSerializer(serializers.Serializer):
class TestPathsListSerializer(serializers.Serializer):
test_path = serializers.CharField()
root_test = serializers.CharField()
aggregation = serializers.CharField()
Expand Down
324 changes: 145 additions & 179 deletions dashboard/core/bots/reports/views.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dashboard/core/bots/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Meta:


class BotsFullDetailsForResultsExistListSerializer(serializers.ModelSerializer):
name = serializers.CharField()
platform = PlatformListSerializer()
cpuArchitecture = CPUArchitectureListSerializer()
gpuType = GPUTypeListSerializer()
Expand Down
37 changes: 9 additions & 28 deletions dashboard/core/bots/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,24 @@
from rest_framework.generics import ListAPIView


class BotsForResultsExistList(ListAPIView):
"""Fetch just the botname for the plot pages"""
class BaseBotResultsView(ListAPIView):
model = Bot
serializer_class = BotsForResultsExistListSerializer

def get_queryset(self):
if self.kwargs.get('browser') == 'all':
browser_obj = Browser.objects.all()
else:
browser_obj = Browser.objects.filter(
pk=self.kwargs.get('browser')
)
browser_filter = self.request.query_params.get('browser', None)
browser_filter_by = {'pk': browser_filter} if browser_filter else {}
browsers = Browser.objects.filter(**browser_filter_by)
return Bot.objects.filter(
name__in=BotReportData.objects.filter(
browser__in=browser_obj
browser__in=browsers
).distinct('bot').values('bot'),
enabled=True
)


class BotsFullDetailsForResultsExistList(ListAPIView):
"""Fetch detailed bot fields for the home page"""
model = Bot
serializer_class = BotsFullDetailsForResultsExistListSerializer

def get_queryset(self):
if self.kwargs.get('browser') == 'all':
browser_obj = Browser.objects.all()
else:
browser_obj = Browser.objects.filter(
pk=self.kwargs.get('browser')
)
return Bot.objects.filter(
name__in=BotReportData.objects.filter(
browser__in=browser_obj
).distinct('bot').values('bot'),
enabled=True
)
class BotsForResultsExistList(BaseBotResultsView):
serializer_class = BotsForResultsExistListSerializer


class BotsFullDetailsForResultsExistList(BaseBotResultsView):
serializer_class = BotsFullDetailsForResultsExistListSerializer
70 changes: 30 additions & 40 deletions dashboard/static/js/app_controllers/dashboard/dashboard.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ app.controller(
$sce, $filter
) {
$scope.browsers = browserFactory.query();
$scope.bots = botFullDetailsForResultsExistFactory.query({
browser: 'all'
});
$scope.bots = botFullDetailsForResultsExistFactory.query({});
$scope.platforms = platformFactory.query();
$scope.gpus = gpuFactory.query();
$scope.cpus = cpuArchFactory.query();
$scope.tests = testsForBrowserAndBotFactory.query({
browser: !$scope.selectedBrowser ? 'all' : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? null : $scope.selectedBot.name,

$scope.tests_query = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? undefined : $scope.selectedBot.name,
});
$scope.tests = testsForBrowserAndBotFactory.query($scope.tests_query);
$scope.botDetailsPopover = {
templateUrl: 'bot-template.html'
};
Expand All @@ -46,13 +46,16 @@ app.controller(
};
$scope.updateOthersOnBrowserChange = function () {
//There can be chance of test change
$scope.tests = testsForBrowserAndBotFactory.query({
browser: !$scope.selectedBrowser ? 'all' : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? null : $scope.selectedBot.name,
}, function () {
$scope.bots = botFullDetailsForResultsExistFactory.query({
browser: !$scope.selectedBrowser ? 'all' : $scope.selectedBrowser.id
$scope.tests_query_on_browser = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? undefined : $scope.selectedBot.name,
});
$scope.tests = testsForBrowserAndBotFactory.query(
$scope.tests_query_on_browser, function () {
$scope.bot_query = angular.extend({}, {
'browser': !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id
});
$scope.bots = botFullDetailsForResultsExistFactory.query($scope.bot_query);
$scope.reload();
});
};
Expand All @@ -72,39 +75,26 @@ app.controller(
$scope.noImprovementsFound = false;
$scope.noRegressionsFound = false;
$scope.loading = true;
$scope.selectedDays = !$scope.selectedDays ? 5 : $scope.selectedDays;
$scope.listLimit = !$scope.listLimit? 10 : $scope.listLimit;
$scope.selectedBrowserId = !$scope.selectedBrowser ? 'all' : $scope.selectedBrowser.id;
$scope.selectedPlatformId = !$scope.selectedPlatform ? 'all' : $scope.selectedPlatform.id;
$scope.selectedCPUId = !$scope.selectedCPU ? 'all' : $scope.selectedCPU.id;
$scope.selectedGPUId = !$scope.selectedGPU ? 'all' : $scope.selectedGPU.id;
$scope.selectedTestId = !$scope.selectedTest ? 'all' : $scope.selectedTest.root_test.id;
$scope.selectedBotName = !$scope.selectedBot ? 'all' : $scope.selectedBot.name;
$scope.improvement_reports = botReportsImprovementFactory.query({
days_since: $scope.selectedDays,
platform: $scope.selectedPlatformId,
gpu: $scope.selectedGPUId,
cpu: $scope.selectedCPUId,
browser: $scope.selectedBrowserId,
test: $scope.selectedTestId,
bot: $scope.selectedBotName,
limit: $scope.listLimit
}, function (data) {
$scope.query_params = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
platform: !$scope.selectedPlatform ? undefined : $scope.selectedPlatform.id,
gpu: !$scope.selectedGPU ? undefined : $scope.selectedGPU.id,
cpu: !$scope.selectedCPU ? undefined : $scope.selectedCPU.id,
test: !$scope.selectedTest ? undefined : $scope.selectedTest.root_test.id,
bot: !$scope.selectedBot ? undefined : $scope.selectedBot.name,
days_since: !$scope.selectedDays ? 5 : $scope.selectedDays,
limit: !$scope.listLimit? 10 : $scope.listLimit
});

$scope.improvement_reports = botReportsImprovementFactory.query(
$scope.query_params, function (data) {
if (data.length == 0) {
$scope.noImprovementsFound = true;
}
$scope.loading_improvements = false;
});
$scope.regression_reports = botReportsRegressionFactory.query({
days_since: $scope.selectedDays,
platform: $scope.selectedPlatformId,
gpu: $scope.selectedGPUId,
cpu: $scope.selectedCPUId,
browser: $scope.selectedBrowserId,
test: $scope.selectedTestId,
bot: $scope.selectedBotName,
limit: $scope.listLimit
}, function (data) {
$scope.regression_reports = botReportsRegressionFactory.query(
$scope.query_params, function (data) {
if (data.length == 0) {
$scope.noRegressionsFound = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
app = angular.module('browserperfdash.dashboard.services', ['ngResource']);

app.factory('botReportsImprovementFactory', function($resource) {
return $resource('/dash/report/improvement/:days_since/:platform/:gpu/:cpu/:browser/:test/:bot/:limit');
return $resource('/dash/report/improvements');
});

app.factory('botReportsRegressionFactory', function($resource) {
return $resource('/dash/report/regression/:days_since/:platform/:gpu/:cpu/:browser/:test/:bot/:limit');
return $resource('/dash/report/regressions');
});

app.factory('browserFactory', function($resource) {
return $resource('/dash/browser_results_exist');
return $resource('/dash/browsers');
});

app.factory('botFullDetailsForResultsExistFactory', function($resource) {
return $resource('/dash/bot_full_details_for_exist/:browser');
return $resource('/dash/bot-full-details');
});

app.factory('platformFactory', function($resource) {
return $resource('/dash/platform_results_exist');
return $resource('/dash/platforms');
});

app.factory('gpuFactory', function($resource) {
return $resource('/dash/gpu_results_exist');
return $resource('/dash/gpus');
});

app.factory('cpuArchFactory', function($resource) {
return $resource('/dash/cpu_results_exist');
return $resource('/dash/cpus');
});

app.factory('testsForBrowserAndBotFactory', function ($resource) {
return $resource('/dash/tests_for_browser_bot/:browser/:bot');
return $resource('/dash/tests');
});
65 changes: 34 additions & 31 deletions dashboard/static/js/app_controllers/plot/plot.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,28 @@ app.controller(

$scope.onBrowserChange = function () {
//Update tests
$scope.tests = testsForBrowserAndBotFactory.query({
browser: !$scope.selectedBrowser ? 'all'
: $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? null : $scope.selectedBot.name
}, function () {
$scope.tests_filter_on_browser = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? undefined : $scope.selectedBot.name
});
$scope.tests = testsForBrowserAndBotFactory.query(
$scope.tests_filter_on_browser, function () {
$scope.selectedTest = $scope.tests[0];
$scope.onTestsChange();
$scope.bots = botForResultsExistFactory.query({
browser: !$scope.selectedBrowser ? 'all'
: $scope.selectedBrowser.id
$scope.query_params = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id
});
$scope.bots = botForResultsExistFactory.query($scope.query_params);
});
};

$scope.onBotsChange = function () {
$scope.tests = testsForBrowserAndBotFactory.query({
browser: !$scope.selectedBrowser ? 'all'
: $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? null : $scope.selectedBot.name
}, function (data) {
$scope.tests_on_bot_change = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
bot: !$scope.selectedBot ? undefined : $scope.selectedBot.name
});
$scope.tests = testsForBrowserAndBotFactory.query(
$scope.tests_on_bot_change, function (data) {
if(data.length === 0) {
$scope.selectedTest = [];
$scope.selectedSubtest = [];
Expand All @@ -76,10 +78,12 @@ app.controller(
if(!$scope.selectedTest) {
return;
}
$scope.subtests = subTestPathFactory.query({
browser: !$scope.selectedBrowser ? 'all' : $scope.selectedBrowser.id,
root_test: $scope.selectedTest.root_test.id
}, function (data) {
$scope.subtests_query = angular.extend({}, {
browser: !$scope.selectedBrowser ? undefined : $scope.selectedBrowser.id,
root_test: !$scope.selectedTest.root_test ? undefined : $scope.selectedTest.root_test.id
});
$scope.subtests = subTestPathFactory.query(
$scope.subtests_query, function (data) {
// We might have something here due to URL data
if (!$scope.selectedSubtest) { $scope.selectedSubtest = data[0]; }
});
Expand Down Expand Up @@ -107,10 +111,7 @@ app.controller(
$scope.bots = botForResultsExistFactory.query({
browser: 'all'
});
$scope.tests = testsForBrowserAndBotFactory.query({
browser: 'all',
bot: null
});
$scope.tests = testsForBrowserAndBotFactory.query();

//Lets just wait for everything to load, and then populate things
$scope.browsers.$promise.then(function () {
Expand All @@ -126,11 +127,11 @@ app.controller(

for ( var i=0; i< plotArray.length; i++ ) {
var value = plotArray[i];
var subtests = subTestPathFactory.query({
browser: value['browser'],
root_test: value['root_test']
$scope.subtests_query_laod = angular.extend({},{
browser: !value['browser'] ? undefined : value['browser'],
root_test: !value['root_test'] ? undefined : value['root_test']
});

var subtests = subTestPathFactory.query($scope.subtests_query_laod);
$scope.drawGraph(
value['browser'], value['bot'], value['root_test'],
value['subtest'], value['seq'], value['start'],
Expand Down Expand Up @@ -200,15 +201,17 @@ app.controller(

testMetricsOfTestAndSubtestFactory.query({
root_test: selectedTest.root_test.id,
subtest: encodeURIComponent(selectedSubtest.test_path),
subtest: encodeURIComponent(selectedSubtest.test_path)
}, function (testMetrics) {
$scope.loading = true;
testResultsForTestAndSubtestFactory.query({
browser: !selectedBrowser ? 'all' : selectedBrowser.id,
root_test: selectedTest.root_test.id,
bot: !selectedBot ? 'all' : selectedBot.name,
$scope.results_query = angular.extend({}, {
browser: !selectedBrowser ? undefined : selectedBrowser.id,
test: !selectedTest.root_test ? undefined : selectedTest.root_test.id,
bot: !selectedBot ? undefined : selectedBot.name,
subtest: encodeURIComponent(selectedSubtest.test_path)
}, function (results) {
});
testResultsForTestAndSubtestFactory.query(
$scope.results_query, function (results){
if (seq !== undefined) {
// This is a draw from the URL - lets use the original sequence for this graph
$scope.graphCounter = seq;
Expand Down
12 changes: 6 additions & 6 deletions dashboard/static/js/app_controllers/plot/plot.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
app = angular.module('browserperfdash.plot.services', ['ngResource']);

app.factory('browserForResultExistFactory', function ($resource) {
return $resource('/dash/browser_results_exist');
return $resource('/dash/browsers');
});

app.factory('botForResultsExistFactory', function($resource) {
return $resource('/dash/bot_results_exist/:browser');
return $resource('/dash/bots');
});

app.factory('testsForBrowserAndBotFactory', function ($resource) {
return $resource('/dash/tests_for_browser_bot/:browser/:bot');
return $resource('/dash/tests');
});

app.factory('subTestPathFactory', function ($resource) {
return $resource('/dash/testpath/:browser/:root_test');
return $resource('/dash/test-paths');
});

app.factory('testMetricsOfTestAndSubtestFactory', function ($resource) {
return $resource('/dash/test_metrics/:root_test/:subtest');
return $resource('/dash/test-metrics/:root_test/:subtest');
});

app.factory('testResultsForTestAndSubtestFactory', function ($resource) {
return $resource('/dash/results_for_subtest/:browser/:root_test/:bot/:subtest/');
return $resource('/dash/results');
});
Loading