Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: dashboard/dashboard/services/issue_tracker_service.py

Issue 2706813003: Add new endpoint to get bug details as JSON. (Closed)
Patch Set: addressed review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dashboard/dashboard/elements/bug-details-test.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides a layer of abstraction for the issue tracker API.""" 5 """Provides a layer of abstraction for the issue tracker API."""
6 6
7 import json 7 import json
8 import logging 8 import logging
9 9
10 from apiclient import discovery 10 from apiclient import discovery
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 projectId='chromium', 163 projectId='chromium',
164 sendEmail=True, 164 sendEmail=True,
165 body=body) 165 body=body)
166 logging.info('Making create issue request with body %s', body) 166 logging.info('Making create issue request with body %s', body)
167 response = self._ExecuteRequest(request) 167 response = self._ExecuteRequest(request)
168 if response and 'id' in response: 168 if response and 'id' in response:
169 return response['id'] 169 return response['id']
170 logging.error('Failed to create new bug; response %s', response) 170 logging.error('Failed to create new bug; response %s', response)
171 return None 171 return None
172 172
173 def GetIssueComments(self, bug_id):
174 """Gets all the comments for the given bug.
175
176 Args:
177 bug_id: Bug ID of the issue to update.
178
179 Returns:
180 A list of comments
181 """
182 if not bug_id or bug_id < 0:
183 return None
184 response = self._MakeGetCommentsRequest(bug_id)
185 if not response:
186 return None
187 return [{
188 'author': r['author'].get('name'),
189 'content': r['content'],
190 'published': r['published']
191 } for r in response.get('items')]
192
173 def GetLastBugCommentsAndTimestamp(self, bug_id): 193 def GetLastBugCommentsAndTimestamp(self, bug_id):
174 """Gets last updated comments and timestamp in the given bug. 194 """Gets last updated comments and timestamp in the given bug.
175 195
176 Args: 196 Args:
177 bug_id: Bug ID of the issue to update. 197 bug_id: Bug ID of the issue to update.
178 198
179 Returns: 199 Returns:
180 A dictionary with last comment and timestamp, or None on failure. 200 A dictionary with last comment and timestamp, or None on failure.
181 """ 201 """
182 if not bug_id or bug_id < 0: 202 if not bug_id or bug_id < 0:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if 'cc' in request_body['updates']: 252 if 'cc' in request_body['updates']:
233 del request_body['updates']['cc'] 253 del request_body['updates']['cc']
234 254
235 255
236 def _GetErrorReason(request_error): 256 def _GetErrorReason(request_error):
237 if request_error.resp.get('content-type', '').startswith('application/json'): 257 if request_error.resp.get('content-type', '').startswith('application/json'):
238 error_json = json.loads(request_error.content).get('error') 258 error_json = json.loads(request_error.content).get('error')
239 if error_json: 259 if error_json:
240 return error_json.get('message') 260 return error_json.get('message')
241 return None 261 return None
OLDNEW
« no previous file with comments | « dashboard/dashboard/elements/bug-details-test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698