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

Side by Side Diff: appengine/cr-buildbucket/api.py

Issue 2170673002: buildbucket: add longest_pending_time API (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: nits Created 4 years, 5 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 | « no previous file | appengine/cr-buildbucket/index.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 )
OLDNEW
« no previous file with comments | « no previous file | appengine/cr-buildbucket/index.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698