<commit_before>﻿using System;
using System.Threading.Tasks;
using CompetitionPlatform.Data.AzureRepositories.Project;
using CompetitionPlatform.Helpers;
using CompetitionPlatform.Models;
using CompetitionPlatform.Services;

namespace CompetitionPlatform.ScheduledJobs
{
    public class StatusUpdater
    {
        private readonly IProjectRepository _projectRepository;
        private readonly IProjectWinnersService _winnersService;

        public StatusUpdater(IProjectRepository projectRepository, IProjectWinnersService winnersService)
        {
            _projectRepository = projectRepository;
            _winnersService = winnersService;
        }

        public async Task UpdateProjectStatuses()
        {
            var projects = await _projectRepository.GetProjectsAsync();

            foreach (var project in projects)
            {
                project.Status = StatusHelper.GetProjectStatusFromString(project.ProjectStatus);

                switch (project.Status)
                {
                    case Status.Initiative:
                        break;
                    case Status.Registration:
                        if (project.CompetitionRegistrationDeadline < DateTime.Today)
                        {
                            project.ProjectStatus = Status.Submission.ToString();
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Submission:
                        if (project.ImplementationDeadline < DateTime.Today)
                        {
                            project.ProjectStatus = project.SkipVoting ? Status.Archive.ToString() : Status.Voting.ToString();
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Voting:
                        if (project.VotingDeadline < DateTime.Today)
                        {
                            project.ProjectStatus = Status.Archive.ToString();
                            await _winnersService.SaveWinners(project.Id);
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Archive:
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }
    }
}
<commit_msg>Add Draft status case to StatusUpdater. Use Utc time.<commit_after>﻿using System;
using System.Threading.Tasks;
using CompetitionPlatform.Data.AzureRepositories.Project;
using CompetitionPlatform.Helpers;
using CompetitionPlatform.Models;
using CompetitionPlatform.Services;

namespace CompetitionPlatform.ScheduledJobs
{
    public class StatusUpdater
    {
        private readonly IProjectRepository _projectRepository;
        private readonly IProjectWinnersService _winnersService;

        public StatusUpdater(IProjectRepository projectRepository, IProjectWinnersService winnersService)
        {
            _projectRepository = projectRepository;
            _winnersService = winnersService;
        }

        public async Task UpdateProjectStatuses()
        {
            var projects = await _projectRepository.GetProjectsAsync();

            foreach (var project in projects)
            {
                project.Status = StatusHelper.GetProjectStatusFromString(project.ProjectStatus);

                switch (project.Status)
                {
                    case Status.Draft:
                        break;
                    case Status.Initiative:
                        break;
                    case Status.Registration:
                        //if (project.CompetitionRegistrationDeadline < DateTime.Today)
                        if (project.CompetitionRegistrationDeadline < DateTime.UtcNow.Date)
                        {
                            project.ProjectStatus = Status.Submission.ToString();
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Submission:
                        //if (project.ImplementationDeadline < DateTime.Today)
                        if (project.ImplementationDeadline < DateTime.UtcNow.Date)
                        {
                            project.ProjectStatus = project.SkipVoting ? Status.Archive.ToString() : Status.Voting.ToString();
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Voting:
                        //if (project.VotingDeadline < DateTime.Today)
                        if (project.VotingDeadline < DateTime.UtcNow.Date)
                        {
                            project.ProjectStatus = Status.Archive.ToString();
                            await _winnersService.SaveWinners(project.Id);
                            await _projectRepository.UpdateAsync(project);
                        }
                        break;
                    case Status.Archive:
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.05879080118694362, 'fraction_numerical': 0.0, 'mean_word_length': 1.3674275680421422, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 3, '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': '4328888', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1066, 'n_words': 210}