<commit_before>using System.Reflection;
using System.Threading.Tasks;
using Bibliotheca.Server.Gateway.Core.DataTransferObjects;
using Bibliotheca.Server.Gateway.Core.Policies;
using Bibliotheca.Server.Gateway.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Bibliotheca.Server.Gateway.Api
{
    /// <summary>
    /// Logs controller.
    /// </summary>
    [ApiVersion("1.0")]
    [Route("api/logs/{projectId}")]
    public class LogsController : Controller
    {
        private readonly IProjectsService _projectsService;

        private readonly IAuthorizationService _authorizationService;

        private readonly ILogsService _logsService;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="projectsService">Project service.</param>
        /// <param name="authorizationService">Authorization service.</param>
        /// <param name="logsService">Logs service.</param>
        public LogsController(
            IProjectsService projectsService, 
            IAuthorizationService authorizationService, 
            ILogsService logsService)
        {
            _projectsService = projectsService;
            _authorizationService = authorizationService;
            _logsService = logsService;
        }

        /// <summary>
        /// Get logs for specific project.
        /// </summary>
        /// <remarks>
        /// Endpoint returns logs information for specific prpoject.
        /// </remarks>
        /// <param name="projectId">Project id.</param>
        /// <returns>Information abouth health.</returns>
        [HttpGet]
        [ProducesResponseType(200, Type = typeof(LogsDto))]
        [ProducesResponseType(404)]
        [ProducesResponseType(403)]
        public async Task<IActionResult> Get(string projectId)
        {
            var projectFromStorage = await _projectsService.GetProjectAsync(projectId);
            if (projectFromStorage == null)
            {
                return NotFound();
            }

            var authorization = await _authorizationService.AuthorizeAsync(User, projectFromStorage, Operations.Read);
            if (!authorization.Succeeded)
            {
                return Forbid();
            }

            var logs = await _logsService.GetLogsAsync(projectId);
            return new ObjectResult(logs);
        }

        /// <summary>
        /// Append logs for specific project.
        /// </summary>
        /// <remarks>
        /// Endpoint appends logs information for specific prpoject.
        /// </remarks>
        /// <param name="projectId">Project id.</param>
        /// <param name="logs">Logs for project.</param>
        /// <returns>Information abouth health.</returns>
        [HttpPut]
        [ProducesResponseType(200)]
        [ProducesResponseType(404)]
        [ProducesResponseType(403)]
        public async Task<IActionResult> Put(string projectId, LogsDto logs)
        {
            var projectFromStorage = await _projectsService.GetProjectAsync(projectId);
            if (projectFromStorage == null)
            {
                return NotFound();
            }

            var authorization = await _authorizationService.AuthorizeAsync(User, projectFromStorage, Operations.Update);
            if (!authorization.Succeeded)
            {
                return Forbid();
            }
<commit_msg>Fix issue with not append message to logs.<commit_after>using System.Reflection;
using System.Threading.Tasks;
using Bibliotheca.Server.Gateway.Core.DataTransferObjects;
using Bibliotheca.Server.Gateway.Core.Policies;
using Bibliotheca.Server.Gateway.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Bibliotheca.Server.Gateway.Api
{
    /// <summary>
    /// Logs controller.
    /// </summary>
    [ApiVersion("1.0")]
    [Route("api/logs/{projectId}")]
    public class LogsController : Controller
    {
        private readonly IProjectsService _projectsService;

        private readonly IAuthorizationService _authorizationService;

        private readonly ILogsService _logsService;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="projectsService">Project service.</param>
        /// <param name="authorizationService">Authorization service.</param>
        /// <param name="logsService">Logs service.</param>
        public LogsController(
            IProjectsService projectsService, 
            IAuthorizationService authorizationService, 
            ILogsService logsService)
        {
            _projectsService = projectsService;
            _authorizationService = authorizationService;
            _logsService = logsService;
        }

        /// <summary>
        /// Get logs for specific project.
        /// </summary>
        /// <remarks>
        /// Endpoint returns logs information for specific prpoject.
        /// </remarks>
        /// <param name="projectId">Project id.</param>
        /// <returns>Information abouth health.</returns>
        [HttpGet]
        [ProducesResponseType(200, Type = typeof(LogsDto))]
        [ProducesResponseType(404)]
        [ProducesResponseType(403)]
        public async Task<IActionResult> Get(string projectId)
        {
            var projectFromStorage = await _projectsService.GetProjectAsync(projectId);
            if (projectFromStorage == null)
            {
                return NotFound();
            }

            var authorization = await _authorizationService.AuthorizeAsync(User, projectFromStorage, Operations.Read);
            if (!authorization.Succeeded)
            {
                return Forbid();
            }

            var logs = await _logsService.GetLogsAsync(projectId);
            return new ObjectResult(logs);
        }

        /// <summary>
        /// Append logs for specific project.
        /// </summary>
        /// <remarks>
        /// Endpoint appends logs information for specific prpoject.
        /// </remarks>
        /// <param name="projectId">Project id.</param>
        /// <param name="logs">Logs for project.</param>
        /// <returns>Information abouth health.</returns>
        [HttpPut]
        [ProducesResponseType(200)]
        [ProducesResponseType(404)]
        [ProducesResponseType(403)]
        public async Task<IActionResult> Put(string projectId, [FromBody] LogsDto logs)
        {
            var projectFromStorage = await _projectsService.GetProjectAsync(projectId);
            if (projectFromStorage == null)
            {
                return NotFound();
            }

            var authorization = await _authorizationService.AuthorizeAsync(User, projectFromStorage, Operations.Update);
            if (!authorization.Succeeded)
            {
                return Forbid();
            }

{'fraction_non_alphanumeric': 0.10550058207217695, 'fraction_numerical': 0.005820721769499418, 'mean_word_length': 2.1127717391304346, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '5935781', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1709, 'n_words': 366}