LCOV - code coverage report
Current view: top level - lib/_classes/storage - history_data.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 14 71.4 %
Date: 2024-10-04 11:12:13 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           3 :   static final _history = HashMap<String, SplayTreeMap<int, TransactionLogData>>();
      13             : 
      14           1 :   static void addLog(uuid, dynamic initial, dynamic initialValue, dynamic value, [String? ref]) {
      15           2 :     if (_history[uuid] == null) {
      16           3 :       _history[uuid] = SplayTreeMap<int, TransactionLogData>();
      17             :     }
      18           1 :     if (initialValue != value) {
      19           7 :       _history[uuid]![-initial.createdAt.millisecondsSinceEpoch] = TransactionLogData(
      20           1 :         timestamp: initial.createdAt,
      21             :         ref: ref,
      22           1 :         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           1 :   static InterfaceIterator<int, dynamic, TransactionLogData>? getStream(String uuid, {Function? filter}) =>
      35           5 :       _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 1.14