<commit_before>﻿using System;

namespace Domion.WebApp.Helpers
{
    public class PagingCalculator
    {
        private const int DefaultPageSize = 10;

        public PagingCalculator(int itemCount, int? pageNumber, int? pageSize)
        {
            if (itemCount < 0) throw new ArgumentOutOfRangeException("Must be > 0", nameof(itemCount));

            Page = pageNumber ?? 1;


            PageSize = pageSize ?? DefaultPageSize;

            if (PageSize < 0) PageSize = DefaultPageSize;

            PageCount = itemCount / PageSize + (itemCount % PageSize > 0 ? 1 : 0);

            if (PageCount == 0) Page = 1;

            if (PageCount > 0 & Page > PageCount) Page = PageCount;

            ItemCount = itemCount;

            if (Page < 0) Page = 1;

            OutOfRange = (pageNumber.HasValue & Page != pageNumber) | (pageSize.HasValue & PageSize != pageSize);
        }

        public int ItemCount { get; private set; }

        public bool OutOfRange { get; private set; }

        public int Page { get; private set; }

        public int PageCount { get; private set; }

        public int PageSize { get; private set; }

        public int Skip => (Page - 1) * PageSize;

        public int Take => PageSize;
    }
}
<commit_msg>Refactored PageSize calculation<commit_after>﻿using System;

namespace Domion.WebApp.Helpers
{
    public class PagingCalculator
    {
        private const int DefaultPageSize = 10;

        public PagingCalculator(int itemCount, int? pageNumber, int? pageSize)
        {
            if (itemCount < 0) throw new ArgumentOutOfRangeException("Must be > 0", nameof(itemCount));

            PageSize = pageSize == null | pageSize < 0 ? DefaultPageSize : pageSize.Value;


            Page = pageNumber ?? 1;




            PageCount = itemCount / PageSize + (itemCount % PageSize > 0 ? 1 : 0);

            if (PageCount == 0) Page = 1;

            if (PageCount > 0 & Page > PageCount) Page = PageCount;

            ItemCount = itemCount;

            if (Page < 0) Page = 1;

            OutOfRange = (pageNumber.HasValue & Page != pageNumber) | (pageSize.HasValue & PageSize != pageSize);
        }

        public int ItemCount { get; private set; }

        public bool OutOfRange { get; private set; }

        public int Page { get; private set; }

        public int PageCount { get; private set; }

        public int PageSize { get; private set; }

        public int Skip => (Page - 1) * PageSize;

        public int Take => PageSize;
    }
}

{'fraction_non_alphanumeric': 0.09629924393155591, 'fraction_numerical': 0.01193792280143255, 'mean_word_length': 2.092250922509225, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '4730767', 'n_tokens_mistral': 758, 'n_tokens_neox': 687, 'n_words': 227}