Skip to content

Commit 307e5a2

Browse files
committed
Minor code optimalisations
1 parent dbb7cfb commit 307e5a2

File tree

5 files changed

+21
-29
lines changed

5 files changed

+21
-29
lines changed

dashboard/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MonitorDashboard(FlaskForm):
1010

1111

1212
class Login(FlaskForm):
13-
""" Used for serving a login form on /{{ link }}/login. """
13+
""" Used for serving a login form. """
1414
name = StringField('Username', [validators.required()])
1515
password = PasswordField('Password', [validators.required()])
1616
submit = SubmitField('Login')

dashboard/routings/result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_dot_charts(end, versions):
130130

131131
def get_boxplots(end, versions):
132132
"""
133-
Function that builds two dot charts:
133+
Function that builds two boxplots:
134134
1. Execution time per version
135135
2. Execution time per user
136136
:param end: the endpoint

dashboard/routings/setup.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@
1919
@blueprint.route('/settings', methods=['GET', 'POST'])
2020
@secure
2121
def settings():
22-
form = ChangeSetting()
22+
password = 'x' * len(config.password)
23+
return render_template('settings.html', link=config.link, session=session, config=config, pw=password)
2324

24-
if request.method == 'POST' and form.validate():
25-
config.username = form.username.data
26-
if form.password.data:
27-
config.password = form.password.data
28-
29-
form.username.data = config.username
30-
old_password = config.password
31-
old_password = 'x' * len(old_password)
3225

33-
return render_template('settings.html', link=config.link, session=session, version=config.version,
34-
database_name=config.database_name, group=config.get_group_by(), form=form,
35-
testDir=config.test_dir, user=config.username, pw=config.password)
26+
def formatter(x):
27+
sec = x // 1000
28+
ms = round(x % 1000, 2)
29+
if sec == 0:
30+
return '{0}ms'.format(ms)
31+
return '{0}s and {1}ms'.format(sec, ms)
3632

3733

3834
@blueprint.route('/rules', methods=['GET', 'POST'])
@@ -119,15 +115,11 @@ def testmonitor():
119115
list_avg.append(d.avg)
120116
list_max.append(d.max)
121117
list_count.append(d.count)
122-
times_chart.add('Minimum', list_min, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x / 1000),
123-
round(x % 1000, 2)))
124-
times_chart.add('Average', list_avg, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x / 1000),
125-
round(x % 1000, 2)))
126-
times_chart.add('Maximum', list_max, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x / 1000),
127-
round(x % 1000, 2)))
118+
times_chart.add('Minimum', list_min, formatter=formatter)
119+
times_chart.add('Average', list_avg, formatter=formatter)
120+
times_chart.add('Maximum', list_max, formatter=formatter)
128121
times_data = times_chart.render_data_uri()
129122

130123
return render_template('testmonitor.html', link=config.link, session=session, curr=3, form=form,
131-
tests=get_tests(),
132-
results=get_results(), res_current_version=get_res_current(config.version),
133-
times_data=times_data)
124+
tests=get_tests(), results=get_results(),
125+
res_current_version=get_res_current(config.version), times_data=times_data)

dashboard/static/assets/css/bootstrap.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/templates/settings.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717
</tr>
1818
<tr>
1919
<td><b>Version of monitored app</b></td>
20-
<td>{{ version }}</td>
20+
<td>{{ config.version }}</td>
2121
</tr>
2222
<tr>
2323
<td><b>Group by variable</b></td>
24-
<td>{{ group if group != None else "Unspecified" }}</td>
24+
<td>{{ config.get_group_by() if config.get_group_by() != None else "Unspecified" }}</td>
2525
</tr>
2626
<tr>
2727
<td><b>Measurements database</b></td>
28-
<td>{{ database_name }}</td>
28+
<td>{{ config.database_name }}</td>
2929
</tr>
3030
<tr>
3131
<td><b>Location of tests of monitored app</b></td>
32-
<td>{{ testDir if testDir != None else "Unspecified" }}</td>
32+
<td>{{ config.test_dir if config.test_dir != None else "Unspecified" }}</td>
3333
</tr>
3434
<tr>
3535
<td><b>Username</b></td>
36-
<td>{{ user }}</td>
36+
<td>{{ config.username }}</td>
3737
</tr>
3838
<tr>
3939
<td><b>Password</b></td>

0 commit comments

Comments
 (0)