<commit_before>﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Context;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace FilterLists.Directory.Application.Queries
{
    public static class GetSoftware
    {
        public class Query : IRequest<IEnumerable<SoftwareViewModel>>
        {
        }

        public class Handler : IRequestHandler<Query, IEnumerable<SoftwareViewModel>>
        {
            private readonly IQueryContext _context;
            private readonly IMapper _mapper;

            public Handler(IQueryContext context, IMapper mapper)
            {
                _context = context;
                _mapper = mapper;
            }

            public async Task<IEnumerable<SoftwareViewModel>> Handle(
                Query request,
                CancellationToken cancellationToken)
            {
                return await _context.Software
                    .ProjectTo<SoftwareViewModel>(_mapper.ConfigurationProvider)
                    .ToListAsync(cancellationToken);
            }
        }

        public class SoftwareViewModelProfile : Profile
        {
            public SoftwareViewModelProfile()
            {
                CreateMap<Software, SoftwareViewModel>();
            }
        }

        public class SoftwareViewModel
        {
            public int Id { get; private set; }
            public string Name { get; private set; } = null!;
            public string? Description { get; private set; }
            public Uri? HomeUrl { get; private set; }
            public Uri? DownloadUrl { get; private set; }
            public bool SupportsAbpUrlScheme { get; private set; }
            public IEnumerable<int>? SyntaxIds { get; private set; }
        }
    }
}<commit_msg>feat(directory): ✨ flesh out GetSoftware query<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Context;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace FilterLists.Directory.Application.Queries
{
    public static class GetSoftware
    {
        public class Query : IRequest<IEnumerable<SoftwareViewModel>>
        {
        }

        public class Handler : IRequestHandler<Query, IEnumerable<SoftwareViewModel>>
        {
            private readonly IQueryContext _context;
            private readonly IMapper _mapper;

            public Handler(IQueryContext context, IMapper mapper)
            {
                _context = context;
                _mapper = mapper;
            }

            public async Task<IEnumerable<SoftwareViewModel>> Handle(
                Query request,
                CancellationToken cancellationToken)
            {
                return await _context.Software
                    .OrderBy(s => s.Id)
                    .ProjectTo<SoftwareViewModel>(_mapper.ConfigurationProvider)
                    .ToListAsync(cancellationToken);
            }
        }

        public class SoftwareViewModelProfile : Profile
        {
            public SoftwareViewModelProfile()
            {
                CreateMap<Software, SoftwareViewModel>()
                    .ForMember(s => s.SyntaxIds,
                        o => o.MapFrom(s =>
                            s.SoftwareSyntaxes.Select(ss => ss.SyntaxId).OrderBy(sid => sid)));
            }
        }

        public class SoftwareViewModel
        {
            public int Id { get; private set; }
            public string Name { get; private set; } = null!;
            public string? Description { get; private set; }
            public Uri? HomeUrl { get; private set; }
            public Uri? DownloadUrl { get; private set; }
            public bool SupportsAbpUrlScheme { get; private set; }
            public IEnumerable<int>? SyntaxIds { get; private set; }
        }
    }
}
{'fraction_non_alphanumeric': 0.07242990654205607, 'fraction_numerical': 0.0, 'mean_word_length': 2.0211714890613974, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3231568', 'n_tokens_mistral': 1051, 'n_tokens_neox': 992, 'n_words': 254}