diff --git a/dashboard/core/bots/authentication_classes.py b/dashboard/core/bots/authentication_classes.py index 40acb8a..a1ced57 100644 --- a/dashboard/core/bots/authentication_classes.py +++ b/dashboard/core/bots/authentication_classes.py @@ -2,9 +2,10 @@ from dashboard.core.bots.models import Bot - class BotAuthentication(authentication.BaseAuthentication): - """Bot authentication view, used to authenticate data sending bots via API""" + """ + Bot authentication view, used to authenticate data sending bots via API + """ def authenticate(self, request): bot_name = request.POST.get('bot_id') diff --git a/dashboard/core/bots/reports/models.py b/dashboard/core/bots/reports/models.py index dc222d5..225b069 100644 --- a/dashboard/core/bots/reports/models.py +++ b/dashboard/core/bots/reports/models.py @@ -9,8 +9,6 @@ from dashboard.core.metric_units.models import MetricUnit - - AGGREGATION_CHOICES = ( ('None', 'None'), ('Total', 'Total'), @@ -20,10 +18,11 @@ class BotReportDataManger(models.Manager): - def create_report(self, bot, browser, browser_version, root_test, - test_path, test_version, aggregation, metric_unit, - metric_unit_prefixed, mean_value, stddev, delta, - is_improvement,prev_result,timestamp=None): + def create_report( + self, bot, browser, browser_version, root_test, + test_path, test_version, aggregation, metric_unit, + metric_unit_prefixed, mean_value, stddev, delta, + is_improvement,prev_result,timestamp=None): bot_report_data = self.create( bot=bot, browser=browser, browser_version=browser_version, root_test=root_test, test_path=test_path, @@ -84,12 +83,17 @@ def save(self, *args, **kwargs): super(BotReportData, self).save(*args, **kwargs) def __unicode__(self): - return self.bot.name + ":" + str(self.browser) \ - + ":" + self.test_version + ":" +\ - self.test_path + ":" + str(self.mean_value) + return '{0}:{1}:{2}:{3}:{4}'.format( + self.bot.name, self.browser, self.test_version, self.test_path, + self.mean_value) + + def __str__(self): + return '{0}:{1}:{2}:{3}:{4}'.format( + self.bot.name, self.browser, self.test_version, self.test_path, + self.mean_value) class Meta: unique_together = ( 'bot', 'browser', 'browser_version', 'root_test', 'test_path', 'test_version', 'metric_unit', 'aggregation', - ) \ No newline at end of file + ) diff --git a/dashboard/core/bots/reports/serializers.py b/dashboard/core/bots/reports/serializers.py index 32d75b8..8e25fc1 100644 --- a/dashboard/core/bots/reports/serializers.py +++ b/dashboard/core/bots/reports/serializers.py @@ -1,3 +1,6 @@ +import base64 +import json + from rest_framework import serializers from dashboard.core.bots.reports.models import BotReportData @@ -38,6 +41,7 @@ class Meta: class BotReportDataSerializer(serializers.ModelSerializer): prev_results = serializers.SerializerMethodField() metric_unit = MetricUnitSerializer() + plot_link = serializers.SerializerMethodField() def get_prev_results(self, obj): if not obj.prev_result: @@ -49,8 +53,37 @@ def get_prev_results(self, obj): "mean_value": obj.prev_result.mean_value, "browser_version": obj.prev_result.browser_version, "stddev": obj.prev_result.stddev, - "metric_unit_prefixed": obj.prev_result.metric_unit_prefixed + "metric_unit_prefixed": obj.prev_result.metric_unit_prefixed, + } + + def get_plot_link(self, obj): + """ + The plot link is a base64 encoded pointer to a plot on graphs/ page + :return: link to plot + """ + plot_data = [ + { + 'browser': obj.browser.id, + 'bot': obj.bot.name, + 'root_test': obj.root_test.id, + 'subtest': obj.test_path, + 'seq': 0, + 'start': float(obj.timestamp.strftime('%s'))*1000, + 'plots': [] } + ] + if obj.prev_result: + plot_data[0].update( + { + 'start': float(obj.prev_result.timestamp.strftime( + '%s'))*1000, + 'end': float(obj.timestamp.strftime('%s'))*1000, + } + ) + return'/dash/graph/#!/{0}'.format( + base64.b64encode(json.dumps(plot_data).encode()).decode() + ) + class Meta: model = BotReportData @@ -58,5 +91,5 @@ class Meta: 'id', 'bot', 'browser', 'browser_version', 'root_test', 'test_path', 'test_version', 'metric_unit', 'metric_unit_prefixed', 'mean_value', 'stddev', 'delta', - 'prev_results' + 'prev_results', 'plot_link', ) diff --git a/dashboard/core/tests/models.py b/dashboard/core/tests/models.py index 03384c8..e86f15c 100644 --- a/dashboard/core/tests/models.py +++ b/dashboard/core/tests/models.py @@ -15,7 +15,7 @@ class Test(models.Model): enabled = models.BooleanField(default=False) def __str__(self): - return self.name + return self.id def __unicode__(self): - return self.id \ No newline at end of file + return self.id diff --git a/dashboard/templates/index.html b/dashboard/templates/index.html index 314d38c..ae50b4a 100644 --- a/dashboard/templates/index.html +++ b/dashboard/templates/index.html @@ -99,11 +99,12 @@ {{ data.test_path }} - + uib-popover-template="testDetailsPopover.templateUrl" + popover-title="test details of both revisions (unchanged)" + href="{{ data.plot_link }}">{{ data.test_path }} {{ data.test_path }} - + uib-popover="Warning: The test version changed in between the revisions." popover-trigger="'mouseenter'" + href="{{ data.plot_link }}">{{ data.test_path }} {{ data.test_path }} - + uib-popover-template="testDetailsPopover.templateUrl" popover-title="test details of both revisions (unchanged)" + href="{{ data.plot_link }}">{{ data.test_path }} {{ data.test_path }} - - + uib-popover="Warning: The test version changed in between the revisions." popover-trigger="'mouseenter'" + href="{{ data.plot_link }}">{{ data.test_path }}