mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
[infra] Handle missing boolean fields in get_builder_status
Change-Id: I0dc03d6dd58c672c843936dc78fd958608ddef35 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130701 Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: William Hesse <whesse@google.com>
This commit is contained in:
parent
3dd8a3b2f3
commit
13fd15d2f0
1 changed files with 9 additions and 7 deletions
|
@ -17,6 +17,12 @@ import 'package:http/http.dart' as http;
|
|||
|
||||
const numAttempts = 20;
|
||||
|
||||
bool booleanFieldOrFalse(Map<String, dynamic> document, String field) {
|
||||
Map<String, dynamic> fieldObject = document['fields'][field];
|
||||
if (fieldObject == null) return false;
|
||||
return fieldObject['booleanValue'] ?? false;
|
||||
}
|
||||
|
||||
void usage(ArgParser parser) {
|
||||
print('''
|
||||
Usage: get_builder_status.dart [OPTIONS]
|
||||
|
@ -93,13 +99,9 @@ main(List<String> args) async {
|
|||
final documents = jsonDecode(response.body);
|
||||
final document = documents.first['document'];
|
||||
if (document != null) {
|
||||
bool success =
|
||||
(document['fields']['success'] ?? const {})['booleanValue'];
|
||||
bool completed =
|
||||
(document['fields']['completed'] ?? const {})['booleanValue'];
|
||||
bool activeFailures =
|
||||
(document['fields']['active_failures'] ?? const {})['booleanValue'];
|
||||
|
||||
bool success = booleanFieldOrFalse(document, 'success');
|
||||
bool completed = booleanFieldOrFalse(document, 'completed');
|
||||
bool activeFailures = booleanFieldOrFalse(document, 'active_failures');
|
||||
if (completed) {
|
||||
if (success) {
|
||||
print('No unapproved new failures');
|
||||
|
|
Loading…
Reference in a new issue