<commit_before>﻿using System;
using System.Threading.Tasks;
using KotoriCore.Commands;
using KotoriCore.Domains;
using KotoriCore.Exceptions;
using KotoriCore.Helpers;
using KotoriCore.Database.DocumentDb.Helpers;
using System.Linq;

namespace KotoriCore.Database.DocumentDb
{
    partial class DocumentDb
    {
        async Task<CommandResult<SimpleDocument>> HandleAsync(FindDocuments command)
        {
            var projectUri = command.ProjectId.ToKotoriUri();

            var project = await FindProjectAsync(command.Instance, projectUri);

            if (project == null)
                throw new KotoriValidationException("Project does not exist.");

            var documentTypeUri = command.DocumentTypeId.ToKotoriUri(true);
            var documentType = await FindDocumentTypeAsync(command.Instance, projectUri, documentTypeUri);

            if (documentType == null)
                throw new KotoriValidationException("Document type does not exist.");

            var sql = DocumentDbHelpers.CreateDynamicQuery
            (
                command.Instance, 
                projectUri, 
                documentTypeUri, <commit_msg>Optimize FindDocuments command, close #18<commit_after>﻿using System;
using System.Threading.Tasks;
using KotoriCore.Commands;
using KotoriCore.Domains;
using KotoriCore.Exceptions;
using KotoriCore.Helpers;
using KotoriCore.Database.DocumentDb.Helpers;
using System.Linq;

namespace KotoriCore.Database.DocumentDb
{
    partial class DocumentDb
    {
        async Task<CommandResult<SimpleDocument>> HandleAsync(FindDocuments command)
        {
            var projectUri = command.ProjectId.ToKotoriUri();
            var documentTypeUri = command.DocumentTypeId.ToKotoriUri(true);
         
            var sql = DocumentDbHelpers.CreateDynamicQuery
            (
                command.Instance, 
                projectUri, 
                documentTypeUri, 
{'fraction_non_alphanumeric': 0.07235814679854242, 'fraction_numerical': 0.001041124414367517, 'mean_word_length': 2.783464566929134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5625325', 'n_tokens_mistral': 492, 'n_tokens_neox': 481, 'n_words': 108}