in builder/lib/src/builder.dart [137:186]
Future<void> storeChange(Map<String, dynamic> change) async {
countChanges++;
await fetchReviewsAndReverts();
transformChange(change);
final failure = isFailure(change);
bool approved;
var result = await firestore.findResult(change, startIndex, endIndex);
var activeResults = await firestore.findActiveResults(
change['name'], change['configuration']);
if (result == null) {
final approvingIndex = tryApprovals[testResult(change)] ??
allRevertedChanges
.firstWhereOrNull(
(revertedChange) => revertedChange.approveRevert(change))
?.revertIndex;
approved = approvingIndex != null;
final newResult = constructResult(change, startIndex, endIndex,
approved: approved,
landedReviewIndex: approvingIndex,
failure: failure);
await firestore.storeResult(newResult);
if (approved) {
countApprovalsCopied++;
if (countApprovalsCopied <= 10) {
approvalMessages
.add('Copied approval of result ${testResult(change)}');
}
}
} else {
approved = await firestore.updateResult(
result, change['configuration'], startIndex, endIndex,
failure: failure);
}
if (failure && !approved) success = false;
for (final activeResult in activeResults) {
final resultRecord = ResultRecord(activeResult.fields);
// Log error message if any expected invariants are violated
if (resultRecord.blamelistEndIndex >= startIndex ||
!resultRecord.containsActiveConfiguration(change['configuration'])) {
// log('Unexpected active result when processing new change:\n'
// 'Active result: ${untagMap(activeResult.fields)}\n\n'
// 'Change: $change\n\n'
// 'approved: $approved');
}
// Removes the configuration from the list of active configurations.
await firestore.removeActiveConfiguration(
activeResult, change['configuration']);
}
}