<commit_before>﻿using DAL;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using System.Linq;
using System.Threading.Tasks;
using X.PagedList;
using System;
using System.Collections.Generic;

namespace Core.Managers
{
    public class VacancyManager : ManagerBase
    {
        public VacancyManager(string connectionString, IMemoryCache cache)
            : base(connectionString, cache)
        {
        }

        public async Task<IPagedList<DAL.Vacancy>> GetVacancies(int page = 1, int pageSize = 10)
        {
            var key = $"vacancy{page}_{pageSize}";

            var result = _cache.Get(key) as IPagedList<DAL.Vacancy>;

            if (result == null)
            {
                var skip = (page - 1) * pageSize;

                var items = _database
                    .Vacancy
                    .Include(o => o.Category)
                    .Where(o => o.Active)
                    .OrderByDescending(o => o.Id)
                    .Skip(skip)
                    .Take(pageSize).ToList();

                var totalItemsCount = await _database.Vacancy.Where(o => o.Active).CountAsync();

                result = new StaticPagedList<Vacancy>(items, page, pageSize, totalItemsCount);
                _cache.Set(key, result, GetMemoryCacheEntryOptions());
            }

            return result;
        }

        public IList<DAL.Vacancy> GetHotVacancies()
        {
            var key = $"hot_vacancies";
            var size = 5;

            var result = _cache.Get(key) as IList<DAL.Vacancy>;

            if (result == null)
            {
                result = _database
                    .Vacancy
                    .Include(o => o.Category)
                    .Where(o => o.Active)
                    .OrderByDescending(o => o.Id)
                    .Take(size).ToList();

                _cache.Set(key, result, GetMemoryCacheEntryOptions());
            }

            return result;
        }

        public async Task<DAL.Vacancy> Get(int id)
        {
            var key = $"vacancy_{id}";

            var result = _cache.Get(key) as Vacancy;
            result = null;<commit_msg>Update VacancyManager<commit_after>﻿using DAL;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using System.Linq;
using System.Threading.Tasks;
using X.PagedList;
using System;
using System.Collections.Generic;

namespace Core.Managers
{
    public class VacancyManager : ManagerBase
    {
        public VacancyManager(string connectionString, IMemoryCache cache)
            : base(connectionString, cache)
        {
        }

        public async Task<IPagedList<DAL.Vacancy>> GetVacancies(int page = 1, int pageSize = 10)
        {
            var key = $"vacancy{page}_{pageSize}";

            var result = _cache.Get(key) as IPagedList<DAL.Vacancy>;

            if (result == null)
            {
                var skip = (page - 1) * pageSize;

                var items = _database
                    .Vacancy
                    .Include(o => o.Category)
                    .Where(o => o.Active && o.LanguageId == Core.Language.EnglishId)
                    .OrderByDescending(o => o.Id)
                    .Skip(skip)
                    .Take(pageSize).ToList();

                var totalItemsCount = await _database.Vacancy.Where(o => o.Active).CountAsync();

                result = new StaticPagedList<Vacancy>(items, page, pageSize, totalItemsCount);
                _cache.Set(key, result, GetMemoryCacheEntryOptions());
            }

            return result;
        }

        public IList<DAL.Vacancy> GetHotVacancies()
        {
            var key = $"hot_vacancies";
            var size = 5;

            var result = _cache.Get(key) as IList<DAL.Vacancy>;

            if (result == null)
            {
                result = _database
                    .Vacancy
                    .Include(o => o.Category)
                    .Where(o => o.Active && o.LanguageId == Core.Language.EnglishId)
                    .OrderByDescending(o => o.Id)
                    .Take(size).ToList();

                _cache.Set(key, result, GetMemoryCacheEntryOptions());
            }

            return result;
        }

        public async Task<DAL.Vacancy> Get(int id)
        {
            var key = $"vacancy_{id}";

            var result = _cache.Get(key) as Vacancy;
            result = null;
{'fraction_non_alphanumeric': 0.10239061795218764, 'fraction_numerical': 0.0022552999548940008, 'mean_word_length': 1.551783659378596, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, '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': '911932', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1198, 'n_words': 262}