OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:async'; |
| 6 import 'try.dart'; |
| 7 import 'logger.dart'; |
| 8 import 'cache_new.dart'; |
| 9 import 'luci_api.dart'; |
| 10 |
| 11 /// Fetches all builds for a given [commit]-hash, by searching the latest |
| 12 /// [amount] builds. |
| 13 Future<Try<List<BuildDetail>>> fetchBuildsForCommmit(LuciApi api, Logger logger, |
| 14 String client, String commit, CreateCacheFunction createCache, |
| 15 [int amount = 1]) async { |
| 16 logger.debug("Finding primary bots for client $client"); |
| 17 var buildBots = await api.getPrimaryBuilders( |
| 18 client, createCache(duration: new Duration(minutes: 30))); |
| 19 |
| 20 var cache = createCache(duration: new Duration(minutes: 30)); |
| 21 return (await buildBots.bindAsync((List<LuciBuildBot> buildBots) async { |
| 22 var buildBotBuilds = new List<List<BuildDetail>>(); |
| 23 for (var buildBot in buildBots) { |
| 24 (await api.getBuildBotDetails(client, buildBot.name, cache, amount)).fold( |
| 25 (ex, st) { |
| 26 logger.error("Problem getting results", ex, st); |
| 27 }, buildBotBuilds.add); |
| 28 } |
| 29 logger.debug("All latest $amount builds found for client $client. " |
| 30 "Processing results..."); |
| 31 return buildBotBuilds.expand((id) => id).toList(); |
| 32 })).bind((List<BuildDetail> buildDetails) { |
| 33 return buildDetails.where((BuildDetail buildDetail) { |
| 34 return buildDetail.allChanges.any((change) => change.revision == commit); |
| 35 }); |
| 36 }); |
| 37 } |
OLD | NEW |