LCOV - code coverage report
Current view: top level - lib/data/models/mobility - route_model.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 13 13 100.0 %
Date: 2020-06-26 11:36:11 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:app_pym/data/models/mobility/calendar_model.dart';
       2             : import 'package:app_pym/data/models/mobility/stop_model.dart';
       3             : import 'package:app_pym/data/models/mobility/stop_time_model.dart';
       4             : import 'package:app_pym/data/models/mobility/trip_model.dart';
       5             : import 'package:app_pym/domain/entities/mobility/route.dart';
       6             : import 'package:freezed_annotation/freezed_annotation.dart';
       7             : 
       8             : part 'route_model.freezed.dart';
       9             : 
      10             : @freezed
      11             : abstract class RouteModel with _$RouteModel {
      12             :   const factory RouteModel({
      13             :     String route_id,
      14             :     String route_short_name,
      15             :     String route_long_name,
      16             :   }) = _RouteModel;
      17             : }
      18             : 
      19             : extension RouteModelX on RouteModel {
      20           1 :   Route toEntity({
      21             :     @required List<TripModel> tripModels,
      22             :     @required List<CalendarModel> calendarModels,
      23             :     @required List<StopTimeModel> stopTimeModels,
      24             :     @required List<StopModel> stopModels,
      25             :   }) {
      26             :     final List<TripModel> filteredTripModels = tripModels
      27           2 :         .where((tripModel) =>
      28           2 :             tripModel.route_id ==
      29           1 :             this.route_id) // Ne prend que les trips de la route
      30           6 :         .where((tripModel) => calendarModels.map((e) => e.service_id).contains(
      31           1 :             tripModel.service_id)) // Ne prend que les trips avec un calendar
      32           1 :         .toList();
      33           1 :     return Route(
      34           1 :       route_id: this.route_id,
      35           1 :       route_long_name: this.route_long_name,
      36           1 :       route_short_name: this.route_short_name,
      37             :       trips: filteredTripModels
      38           3 :           .map((e) => e.toEntity(
      39             :                 calendarModels: calendarModels,
      40             :                 stopModels: stopModels,
      41             :                 stopTimeModels: stopTimeModels,
      42             :               ))
      43           1 :           .toList(),
      44             :     );
      45             :   }
      46             : }

Generated by: LCOV version 1.13