LCOV - code coverage report
Current view: top level - lib/_classes/structure - summary_app_data.dart Coverage Total Hit
Test: lcov.info Lines: 94.7 % 19 18
Test Date: 2026-11-14 15:08:11 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'dart:collection';
       5              : import 'dart:math';
       6              : 
       7              : import 'package:app_finance/_ext/date_time_ext.dart';
       8              : 
       9              : class SummaryAppData {
      10              :   final _scope = SplayTreeMap<double, String>();
      11              :   final _actual = SplayTreeMap<double, String>();
      12              :   final _hash = HashMap<String, double>();
      13              :   double total;
      14              :   int startingDay;
      15              : 
      16            1 :   SummaryAppData({
      17              :     this.total = 0,
      18              :     this.startingDay = 1,
      19              :     List<String> list = const [],
      20              :   }) {
      21            1 :     this.list = list;
      22              :   }
      23              : 
      24            2 :   SplayTreeMap<double, String> get origin => _scope;
      25              : 
      26            6 :   List<String> get list => _scope.values.toList().reversed.toList();
      27              : 
      28            6 :   List<String> get listActual => _actual.values.toList().reversed.toList();
      29              : 
      30            1 :   set list(List<String> list) {
      31            2 :     for (int i = 0; i < list.length; i++) {
      32            0 :       add(list[i], id: i + 1);
      33              :     }
      34              :   }
      35              : 
      36            1 :   add(String value, {DateTime? updatedAt, int? id}) {
      37            2 :     if (_hash.containsKey(value)) {
      38            4 :       _scope.remove(_hash[value]);
      39            4 :       _actual.remove(_hash[value]);
      40            2 :       _hash.remove(value);
      41              :     }
      42            1 :     final current = DateTime.now();
      43              :     updatedAt ??= current;
      44            5 :     double key = (id ?? updatedAt.millisecondsSinceEpoch).toDouble() + Random().nextDouble();
      45            2 :     _scope[key] = value;
      46            2 :     _hash[value] = key;
      47            4 :     if (key >= current.getStartingDay(startingDay).millisecondsSinceEpoch) {
      48            2 :       _actual[key] = value;
      49              :     }
      50              :   }
      51              : }
        

Generated by: LCOV version 2.0-1