LCOV - code coverage report
Current view: top level - _classes/structure - summary_app_data.dart Coverage Total Hit
Test: lcov.info Lines: 78.9 % 19 15
Test Date: 2026-11-14 15:03:01 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            2 :   SummaryAppData({
      17              :     this.total = 0,
      18              :     this.startingDay = 1,
      19              :     List<String> list = const [],
      20              :   }) {
      21            2 :     this.list = list;
      22              :   }
      23              : 
      24            0 :   SplayTreeMap<double, String> get origin => _scope;
      25              : 
      26           12 :   List<String> get list => _scope.values.toList().reversed.toList();
      27              : 
      28            6 :   List<String> get listActual => _actual.values.toList().reversed.toList();
      29              : 
      30            2 :   set list(List<String> list) {
      31            6 :     for (int i = 0; i < list.length; i++) {
      32            6 :       add(list[i], id: i + 1);
      33              :     }
      34              :   }
      35              : 
      36            2 :   add(String value, {DateTime? updatedAt, int? id}) {
      37            4 :     if (_hash.containsKey(value)) {
      38            0 :       _scope.remove(_hash[value]);
      39            0 :       _actual.remove(_hash[value]);
      40            0 :       _hash.remove(value);
      41              :     }
      42            2 :     final current = DateTime.now();
      43              :     updatedAt ??= current;
      44            9 :     double key = (id ?? updatedAt.millisecondsSinceEpoch).toDouble() + Random().nextDouble();
      45            4 :     _scope[key] = value;
      46            4 :     _hash[value] = key;
      47            8 :     if (key >= current.getStartingDay(startingDay).millisecondsSinceEpoch) {
      48            2 :       _actual[key] = value;
      49              :     }
      50              :   }
      51              : }
        

Generated by: LCOV version 2.0-1