Skip to content

Commit 25085ee

Browse files
author
Matthew Fisher
committed
ref(controller): small optimizations
We don't need to create a variable for something that we reference only once, and we don't need to throw an independent call into a try/catch block if it's not required.
1 parent 360b1ed commit 25085ee

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

controller/api/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ def logs(self, request, **kwargs):
158158

159159
def run(self, request, **kwargs):
160160
app = self.get_object()
161-
command = request.data['command']
162161
try:
163-
output_and_rc = app.run(self.request.user, command)
162+
output_and_rc = app.run(self.request.user, request.data['command'])
164163
except EnvironmentError as e:
165164
return Response({'detail': str(e)}, status=status.HTTP_400_BAD_REQUEST)
166165
except RuntimeError as e:
@@ -239,8 +238,8 @@ def rollback(self, request, **kwargs):
239238
Create a new release as a copy of the state of the compiled slug and config vars of a
240239
previous release.
241240
"""
241+
app = self.get_app()
242242
try:
243-
app = self.get_app()
244243
release = app.release_set.latest()
245244
version_to_rollback_to = release.version - 1
246245
if request.data.get('version'):

0 commit comments

Comments
 (0)