| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import functools | 5 import functools |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
| 10 from protorpc import messages | 10 from protorpc import messages |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 raise acl.current_identity_cannot('access bucket %s', request.bucket) | 644 raise acl.current_identity_cannot('access bucket %s', request.bucket) |
| 645 bucket = config.Bucket.get_by_id(request.bucket) | 645 bucket = config.Bucket.get_by_id(request.bucket) |
| 646 if not bucket: | 646 if not bucket: |
| 647 raise endpoints.NotFoundException('bucket %s not found' % request.bucket) | 647 raise endpoints.NotFoundException('bucket %s not found' % request.bucket) |
| 648 return BucketMessage( | 648 return BucketMessage( |
| 649 name=request.bucket, | 649 name=request.bucket, |
| 650 project_id=bucket.project_id, | 650 project_id=bucket.project_id, |
| 651 config_file_content=bucket.config_content, | 651 config_file_content=bucket.config_content, |
| 652 config_file_rev=bucket.revision, | 652 config_file_rev=bucket.revision, |
| 653 config_file_url=config.get_buildbucket_cfg_url(bucket.project_id), | 653 config_file_url=config.get_buildbucket_cfg_url(bucket.project_id), |
| 654 ) | 654 ) |
| 655 |
| 656 ########################### LONGEST_PENDING_TIME ############################ |
| 657 |
| 658 class LongestPendingTimeResponse(messages.Message): |
| 659 longest_pending_time_sec = messages.FloatField(1) |
| 660 error = messages.MessageField(ErrorMessage, 2) |
| 661 |
| 662 @buildbucket_api_method( |
| 663 endpoints.ResourceContainer( |
| 664 message_types.VoidMessage, |
| 665 bucket=messages.StringField(1, required=True), |
| 666 builder=messages.StringField(2, required=True), |
| 667 ), |
| 668 LongestPendingTimeResponse, |
| 669 path='metrics/longest-pending-time', http_method='GET') |
| 670 @auth.public |
| 671 def longest_pending_time(self, request): |
| 672 """Returns longest pending time among all SCHEDULED builds of a builder.""" |
| 673 wait_time = service.longest_pending_time(request.bucket, request.builder) |
| 674 return self.LongestPendingTimeResponse( |
| 675 longest_pending_time_sec=wait_time.total_seconds(), |
| 676 ) |
| OLD | NEW |