<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PackTracker.Entity;

namespace PackTracker.View {
  public class PityTimer : INotifyPropertyChanged {
    int _packId;
    bool _waitForFirst;
    Func<Pack, bool> _condition;

    int _current = 0;
    ObservableCollection<int> _prev = new ObservableCollection<int>();

    public int Current { get => _current; }
    public ObservableCollection<int> Prev { get => _prev; }
    public int? Average { get => _prev.Count > 0 ? (int?)Math.Round(_prev.Average(), 0) : null; }

    public PityTimer(History History, int packId, Func<Pack, bool> Condition, bool skipFirst) {
      _packId = packId;
      _waitForFirst = skipFirst;
      _condition = Condition;

      foreach(Pack Pack in History) {
        AddPack(Pack);
      }

      History.CollectionChanged += (sender, e) => {
        if(e.Action == NotifyCollectionChangedAction.Add) {
          foreach(Pack Pack in e.NewItems) {
            AddPack(Pack);
          }
        }
      };
    }

    void AddPack(Pack Pack) {
      if(Pack.Id != _packId) {
        return;
      }

      if(_condition(Pack)) {
        if(_waitForFirst) {
          _waitForFirst = false;
        } else {
          _prev.Add(_current);
          _current = 0;
          OnPropertyChanged("Current");
          OnPropertyChanged("Average");
        }
      } else {
        if(!_waitForFirst) {
          _current++;
          OnPropertyChanged("Current");
        }
      }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged(string prop) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
  }
}
<commit_msg>PityTimer reworked: Current count always<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PackTracker.Entity;

namespace PackTracker.View {
  public class PityTimer : INotifyPropertyChanged {
    int _packId;
    bool _waitForFirst;
    Func<Pack, bool> _condition;

    int _current = 0;
    ObservableCollection<int> _prev = new ObservableCollection<int>();

    public int Current { get => _current; }
    public ObservableCollection<int> Prev { get => _prev; }
    public int? Average { get => _prev.Count > 0 ? (int?)Math.Round(_prev.Average(), 0) : null; }

    public PityTimer(History History, int packId, Func<Pack, bool> Condition, bool skipFirst) {
      _packId = packId;
      _waitForFirst = skipFirst;
      _condition = Condition;

      foreach(Pack Pack in History) {
        AddPack(Pack);
      }

      History.CollectionChanged += (sender, e) => {
        if(e.Action == NotifyCollectionChangedAction.Add) {
          foreach(Pack Pack in e.NewItems) {
            AddPack(Pack);
          }
        }
      };
    }

    void AddPack(Pack Pack) {
      if(Pack.Id != _packId) {
        return;
      }

      _current++;

      if(_condition(Pack)) {
        if(_waitForFirst) {
          _waitForFirst = false;
        } else {
          _prev.Add(_current);
          OnPropertyChanged("Average");
        }
        _current = 0;
      }

      OnPropertyChanged("Current");
    }

    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged(string prop) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
  }
}

{'fraction_non_alphanumeric': 0.10664094791953706, 'fraction_numerical': 0.002204464039680353, 'mean_word_length': 2.7192622950819674, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4416383', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1026, 'n_words': 237}