| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'buildbot_data.dart'; | 7 import 'buildbot_data.dart'; |
| 8 import 'buildbot_structures.dart'; | 8 import 'buildbot_structures.dart'; |
| 9 import 'client.dart'; | 9 import 'client.dart'; |
| 10 import 'util.dart'; | 10 import 'util.dart'; |
| 11 | 11 |
| 12 class Bot { | 12 class Bot { |
| 13 final bool usesLogdog; | 13 final bool usesLogdog; |
| 14 final BuildbotClient _client; | 14 final BuildbotClient _client; |
| 15 | 15 |
| 16 /// Instantiates a Bot. | 16 /// Instantiates a Bot. |
| 17 /// | 17 /// |
| 18 /// Bots must be [close]d when they aren't needed anymore. | 18 /// Bots must be [close]d when they aren't needed anymore. |
| 19 Bot({bool logdog = false}) | 19 Bot({bool logdog = false}) |
| 20 : usesLogdog = logdog, | 20 : usesLogdog = logdog, |
| 21 _client = | 21 _client = |
| 22 logdog ? new LogdogBuildbotClient() : new HttpBuildbotClient(); | 22 logdog ? new LogdogBuildbotClient() : new HttpBuildbotClient(); |
| 23 | 23 |
| 24 int get mostRecentBuildNumber => _client.mostRecentBuildNumber; |
| 25 |
| 24 /// Reads the build result of [buildUri] and the [previousCount] earlier | 26 /// Reads the build result of [buildUri] and the [previousCount] earlier |
| 25 /// builds. | 27 /// builds. |
| 26 Future<List<BuildResult>> readHistoricResults(BuildUri buildUri, | 28 Future<List<BuildResult>> readHistoricResults(BuildUri buildUri, |
| 27 {int previousCount = 0}) { | 29 {int previousCount = 0}) { |
| 28 log("Fetching $buildUri and $previousCount previous builds in parallel"); | 30 log("Fetching $buildUri and $previousCount previous builds in parallel"); |
| 29 var uris = [buildUri]; | 31 var uris = [buildUri]; |
| 30 for (int i = 0; i < previousCount; i++) { | 32 for (int i = 0; i < previousCount; i++) { |
| 31 buildUri = buildUri.prev(); | 33 buildUri = buildUri.prev(); |
| 32 uris.add(buildUri); | 34 uris.add(buildUri); |
| 33 } | 35 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 60 }))); | 62 }))); |
| 61 i = end + 1; | 63 i = end + 1; |
| 62 } | 64 } |
| 63 return result; | 65 return result; |
| 64 } | 66 } |
| 65 | 67 |
| 66 /// Returns uris for the most recent build of all build groups. | 68 /// Returns uris for the most recent build of all build groups. |
| 67 List<BuildUri> get mostRecentUris { | 69 List<BuildUri> get mostRecentUris { |
| 68 List<BuildUri> result = []; | 70 List<BuildUri> result = []; |
| 69 for (BuildGroup group in buildGroups) { | 71 for (BuildGroup group in buildGroups) { |
| 70 result.addAll(group.createUris(_client.mostRecentBuildNumber)); | 72 result.addAll(group.createUris(mostRecentBuildNumber)); |
| 71 } | 73 } |
| 72 return result; | 74 return result; |
| 73 } | 75 } |
| 74 | 76 |
| 75 /// Closes the bot. | 77 /// Closes the bot. |
| 76 void close() => _client.close(); | 78 void close() => _client.close(); |
| 77 } | 79 } |
| OLD | NEW |