Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import 'dart:async'; | |
| 2 import 'dart:math'; | |
| 3 import 'try.dart'; | |
| 4 import 'logger.dart'; | |
| 5 import 'cache_new.dart'; | |
| 6 import 'luci_api.dart'; | |
| 7 | |
| 8 // /// Fetches the latest builds for a bot and caches the results. | |
| 9 // Future<Try<List<BuildDetail>>> fetchAndCacheLatestBuilds( | |
| 10 // LuciApi api, | |
| 11 // Logger logger, | |
| 12 // String client, | |
| 13 // String botName, | |
| 14 // CreateCacheFunction createCache, | |
| 15 // int amount) async { | |
| 16 // logger.debug("Finding latest build for bot $botName..."); | |
| 17 // var result = await api.getBuildBotDetails( | |
| 18 // client, botName, createCache(duration: new Duration(minutes: 15))); | |
| 19 // return result | |
| 20 // .bindAsync<List<BuildDetail>>((LuciBuildBotDetail botDetail) async { | |
| 21 // int buildNo = botDetail.latestBuildNumber(); | |
| 22 // int lo = max(0, buildNo - amount); | |
| 23 // List<Future<Try<BuildDetail>>> builds = | |
| 24 // new List<Future<Try<BuildDetail>>>(); | |
| 25 // logger.debug("Finding builds #${lo}-#${buildNo} for bot $botName..."); | |
| 26 // for (buildNo; buildNo > lo; buildNo--) { | |
| 27 // builds.add(api.getBuildDetails( | |
| 28 // client, botName, buildNo, cache(duration: new Duration(days: 1)))); | |
| 29 // } | |
| 30 // List<Try<BuildDetail>> buildsCompleted = await Future.wait(builds); | |
| 31 // logger.debug("Finished finding builds for bot $botName"); | |
| 32 // return buildsCompleted | |
| 33 // .where((bd) => !bd.isError()) | |
| 34 // .map((bd) => bd.get()) | |
| 35 // .toList(); | |
| 36 // }); | |
| 37 // } | |
| 38 | |
| 39 /// Fetches all builds for a given [commit]-hash, by searching the latest [amoun t] builds. | |
|
Johnni Winther
2017/08/28 07:14:04
Long line.
| |
| 40 Future<Try<List<BuildDetail>>> fetchBuildsForCommmit(LuciApi api, Logger logger, | |
| 41 String client, String commit, CreateCacheFunction createCache, | |
| 42 [int amount = 1]) async { | |
| 43 logger.debug("Finding primary bots for client $client"); | |
| 44 var buildBots = await api.getPrimaryBuilders( | |
| 45 client, createCache(duration: new Duration(minutes: 30))); | |
| 46 | |
| 47 var cache = createCache(duration: new Duration(minutes: 30)); | |
| 48 return (await buildBots.bindAsync((List<LuciBuildBot> buildBots) async { | |
| 49 var buildBotBuilds = new List<List<BuildDetail>>(); | |
| 50 for (var buildBot in buildBots) { | |
| 51 (await api.getBuildBotDetails(client, buildBot.name, cache, amount)).fold( | |
| 52 (ex, st) { | |
| 53 logger.error("Problem getting results", ex, st); | |
| 54 }, buildBotBuilds.add); | |
| 55 } | |
| 56 logger.debug( | |
| 57 "All latest $amount builds found for client $client. Processing results. .."); | |
|
Johnni Winther
2017/08/28 07:14:04
Long line.
| |
| 58 return buildBotBuilds.expand((id) => id).toList(); | |
| 59 })).bind((List<BuildDetail> buildDetails) { | |
| 60 return buildDetails.where((BuildDetail buildDetail) { | |
| 61 return buildDetail.allChanges.any((change) => change.revision == commit); | |
| 62 }); | |
| 63 }); | |
| 64 } | |
| OLD | NEW |