hasDefectEntries method

Future<bool> hasDefectEntries(
  1. InspectionLocation inspection
)

Implementation

Future<bool> hasDefectEntries(InspectionLocation inspection) async {
  final categories = (await _loadCategories(inspection))
      .where((category) => _belongsToParent(category, inspection.id));
  for (final category in categories) {
    final checkpoints = (await _loadCheckpoints(category))
        .where((checkpoint) => _belongsToParent(checkpoint, category.id));
    for (final checkpoint in checkpoints) {
      final defects = (await _loadDefects(checkpoint))
          .where((defect) => _belongsToParent(defect, checkpoint.id));
      if (defects.isNotEmpty) return true;
    }
  }
  return false;
}