<commit_before>﻿using LearnWordsFast.API.Exceptions;
using LearnWordsFast.API.Services;
using LearnWordsFast.API.ViewModels.TrainingController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace LearnWordsFast.API.Controllers
{
    [Route("api/Training")]
    [Authorize]
    public class TrainingController : ApiController
    {
        private readonly ITrainingService _trainingService;
        private readonly ILogger<TrainingController> _log;

        public TrainingController(
            ITrainingService trainingService,
            ILogger<TrainingController> log)
        {
            _trainingService = trainingService;
            _log = log;
        }

        [HttpGet]
        public IActionResult Get()
        {
            _log.LogInformation("Get next training");
            var training = _trainingService.CreateTraining(UserId);
            if (training == null)
            {
                return NotFound();
            }

            return Ok(training);
        }<commit_msg>Update Authorize attribute to use Bearer policy<commit_after>﻿using LearnWordsFast.API.Exceptions;
using LearnWordsFast.API.Services;
using LearnWordsFast.API.ViewModels.TrainingController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace LearnWordsFast.API.Controllers
{
    [Route("api/Training")]
    [Authorize("Bearer")]
    public class TrainingController : ApiController
    {
        private readonly ITrainingService _trainingService;
        private readonly ILogger<TrainingController> _log;

        public TrainingController(
            ITrainingService trainingService,
            ILogger<TrainingController> log)
        {
            _trainingService = trainingService;
            _log = log;
        }

        [HttpGet]
        public IActionResult Get()
        {
            _log.LogInformation("Get next training");
            var training = _trainingService.CreateTraining(UserId);
            if (training == null)
            {
                return NotFound();
            }

            return Ok(training);
        }
{'fraction_non_alphanumeric': 0.075591985428051, 'fraction_numerical': 0.0, 'mean_word_length': 2.470774091627172, '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': '7246423', 'n_tokens_mistral': 545, 'n_tokens_neox': 534, 'n_words': 116}