Index: third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py |
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py |
index bab2b1cb1ab3ccaa8096bdda13751c06f49c3701..b2bfc77adef2bef29110a7960e085cbbf2fbb9c2 100644 |
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py |
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py |
@@ -130,3 +130,24 @@ def current_build_link(host): |
if not (master_name and builder_name and build_number): |
return None |
return 'https://build.chromium.org/p/%s/builders/%s/builds/%s' % (master_name, builder_name, build_number) |
+ |
+ |
+def filter_latest_builds(builds): |
+ """Filters Build objects to include only the latest for each builder. |
+ |
+ Args: |
+ builds: A collection of Build objects. |
+ |
+ Returns: |
+ A list of Build objects; only one Build object per builder name. If |
+ there are only Builds with no build number, then one is kept; if there |
+ are Builds with build numbers, then the one with the highest build |
+ number is kept. Builds with the highest |
+ """ |
+ builder_to_latest_build = {} |
+ for build in builds: |
+ if build.builder_name not in builder_to_latest_build: |
+ builder_to_latest_build[build.builder_name] = build |
+ elif build.build_number > builder_to_latest_build[build.builder_name].build_number: |
+ builder_to_latest_build[build.builder_name] = build |
wkorman
2017/02/17 23:24:00
Same as two lines up -- could turn these 4 lines i
qyearsley
2017/02/17 23:45:34
Yep! Good catch. Now removed this repetition.
|
+ return sorted(builder_to_latest_build.values()) |