<commit_before>﻿using System;
using Common;

namespace LtcService
{
    public class Evaluator
    {
        private const int TicksAfterRise = 4;
        private readonly SettingsManager _settingsManager;

        public Evaluator(IEventLogger eventLogger)
        {
            _settingsManager = new SettingsManager(eventLogger);
            var settings = _settingsManager.LoadSettings();
            CheckToday(settings);
            settings.LogoutCountdown = TicksAfterRise;
            settings.LogoutStarted = false;
            _settingsManager.SaveSettings(settings);
        }

        public bool Tick()
        {
            var result = false;
            var settings = _settingsManager.LoadSettings();
            CheckToday(settings);

            settings.TodayRemainsMinutes--;
            if (settings.TodayRemainsMinutes < TicksAfterRise || !settings.IsInAllovedIntervals(DateTime.Now.AddMinutes(TicksAfterRise)))
            {
                settings.LogoutStarted = true;
                settings.LogoutCountdown--;
                if (settings.LogoutCountdown <= 0)
                {
                    settings.LogoutStarted = false;
                    settings.LogoutCountdown = TicksAfterRise;
                    result = true;
                }
            }
            else
            {
                ResetCountdown(settings);
            }
            _settingsManager.SaveSettings(settings);
            return result;
        }

        public void ResetCountdown()
        {
            var settings = _settingsManager.LoadSettings();
            ResetCountdown(settings);
            _settingsManager.SaveSettings(settings);
        }


        private void ResetCountdown(Settings settings)
        {
            settings.LogoutStarted = false;
            settings.LogoutCountdown = TicksAfterRise;
        }

        private void CheckToday(Settings settings)
        {
            var today = DateTime.Now.ToShortDateString();
            if (settings.ActualDay != today)
            {
                settings.ActualDay = today;
                settings.TodayRemainsMinutes = settings.TodayLimit;
                settings.LogoutCountdown = TicksAfterRise;
                settings.LogoutStarted = false;
            }
            ;
        }
    }
}<commit_msg>evaluator - decrease logoff limit after enforced logoff<commit_after>﻿using System;
using Common;

namespace LtcService
{
    public class Evaluator
    {
        private const int TicksForCountDown = 4;
        private const int TicksAfterLogOff = 2;
        private readonly SettingsManager _settingsManager;

        public Evaluator(IEventLogger eventLogger)
        {
            _settingsManager = new SettingsManager(eventLogger);
            var settings = _settingsManager.LoadSettings();
            CheckToday(settings);
            settings.LogoutCountdown = TicksForCountDown;
            settings.LogoutStarted = false;
            _settingsManager.SaveSettings(settings);
        }

        public bool Tick()
        {
            var result = false;
            var settings = _settingsManager.LoadSettings();
            CheckToday(settings);

            settings.TodayRemainsMinutes--;
            if (settings.TodayRemainsMinutes < TicksForCountDown || !settings.IsInAllovedIntervals(DateTime.Now.AddMinutes(TicksForCountDown)))
            {
                settings.LogoutStarted = true;
                settings.LogoutCountdown--;
                if (settings.LogoutCountdown <= 0)
                {
                    settings.LogoutStarted = false;
                    settings.LogoutCountdown = TicksAfterLogOff;
                    result = true;
                }
            }
            else
            {
                ResetCountdown(settings);
            }
            _settingsManager.SaveSettings(settings);
            return result;
        }

        public void ResetCountdown()
        {
            var settings = _settingsManager.LoadSettings();
            ResetCountdown(settings);
            _settingsManager.SaveSettings(settings);
        }


        private void ResetCountdown(Settings settings)
        {
            settings.LogoutStarted = false;
            settings.LogoutCountdown = TicksForCountDown;
        }

        private void CheckToday(Settings settings)
        {
            var today = DateTime.Now.ToShortDateString();
            if (settings.ActualDay != today)
            {
                settings.ActualDay = today;
                settings.TodayRemainsMinutes = settings.TodayLimit;
                ResetCountdown(settings);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06952216960826517, 'fraction_numerical': 0.001076194575979337, 'mean_word_length': 1.6358479863868407, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '2636098', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1084, 'n_words': 206}