LCOV - code coverage report
Current view: top level - _classes/storage - history_data.dart Coverage Total Hit
Test: lcov.info Lines: 57.1 % 14 8
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              : 
       6              : import 'package:app_finance/_classes/controller/iterator_controller.dart';
       7              : import 'package:app_finance/_classes/structure/interface_app_data.dart';
       8              : import 'package:app_finance/_classes/structure/transaction_log_data.dart';
       9              : import 'package:app_finance/_ext/iterable_ext.dart';
      10              : 
      11              : class HistoryData {
      12            6 :   static final _history = HashMap<String, SplayTreeMap<int, TransactionLogData>>();
      13              : 
      14            2 :   static void addLog(uuid, dynamic initial, dynamic initialValue, dynamic value, [String? ref]) {
      15            4 :     if (_history[uuid] == null) {
      16            6 :       _history[uuid] = SplayTreeMap<int, TransactionLogData>();
      17              :     }
      18            2 :     if (initialValue != value) {
      19           14 :       _history[uuid]![-initial.createdAt.millisecondsSinceEpoch] = TransactionLogData(
      20            2 :         timestamp: initial.createdAt,
      21              :         ref: ref,
      22            2 :         currency: initial.currency,
      23              :         name: 'details',
      24              :         changedFrom: initialValue,
      25              :         changedTo: value,
      26              :       );
      27              :     }
      28              :   }
      29              : 
      30            0 :   static List<TransactionLogData>? getLog(String uuid) {
      31            0 :     return _history[uuid]?.values.map((e) => e.clone()).toList();
      32              :   }
      33              : 
      34            0 :   static InterfaceIterator<int, dynamic, TransactionLogData>? getStream(String uuid, {Function? filter}) =>
      35            0 :       _history[uuid]?.toStream<TransactionLogData>(false, filter: filter, transform: (e) => e.clone());
      36              : 
      37            0 :   static List<List<TransactionLogData>?> getMultiLog(List<InterfaceAppData> scope) {
      38            0 :     return scope.map((e) => getLog(e.uuid!)).toList();
      39              :   }
      40              : }
        

Generated by: LCOV version 2.0-1