diff --git a/src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs b/src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs index cbfc4ff0..57088518 100644 --- a/src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs +++ b/src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs @@ -19,6 +19,19 @@ WHERE t.has_concrete_reviewer .Column("has_concrete_reviewer") .FromTable("task_for_reviews") .InSchema("review"); + + Execute.Sql( + """ + UPDATE review.task_for_reviews AS t + SET state = 5 + WHERE t.accepted_with_comments + """, + "Set state by accepted_with_comments"); + + Delete + .Column("accepted_with_comments") + .FromTable("task_for_reviews") + .InSchema("review"); } public override void Down() @@ -37,5 +50,36 @@ UPDATE review.task_for_reviews AS t SET has_concrete_reviewer = t.strategy = 3; """, "Set has_concrete_reviewer by strategy"); + + Execute.Sql( + """ + UPDATE review.task_for_reviews + SET strategy = 2 + WHERE strategy = 3; + """, + "Change strategy"); + + Create + .Column("accepted_with_comments") + .OnTable("task_for_reviews") + .InSchema("review") + .AsBoolean() + .NotNullable() + .SetExistingRowsTo(false); + + Execute.Sql( + """ + UPDATE review.task_for_reviews AS t + SET accepted_with_comments = t.state = 5; + """, + "Set has_concrete_reviewer by strategy"); + + Execute.Sql( + """ + UPDATE review.task_for_reviews + SET state = 4 + WHERE state = 5; + """, + "Change state"); } } \ No newline at end of file diff --git a/src/Inc.TeamAssistant.Primitives/Icons.cs b/src/Inc.TeamAssistant.Primitives/Icons.cs index fb1e8630..03635597 100644 --- a/src/Inc.TeamAssistant.Primitives/Icons.cs +++ b/src/Inc.TeamAssistant.Primitives/Icons.cs @@ -9,6 +9,7 @@ public static class Icons public static readonly string InProgress = "🤩"; public static readonly string OnCorrection = "😱"; public static readonly string Accept = "🤝"; + public static readonly string AcceptWithComments = "🙏"; public static readonly string Comment = "💬"; public static readonly string Start = "⭐"; public static readonly string Ok = "👌"; diff --git a/src/Inc.TeamAssistant.Reviewer.Application/CommandHandlers/MoveToAccept/MoveToAcceptCommandHandler.cs b/src/Inc.TeamAssistant.Reviewer.Application/CommandHandlers/MoveToAccept/MoveToAcceptCommandHandler.cs index e16a48c3..9c7905ae 100644 --- a/src/Inc.TeamAssistant.Reviewer.Application/CommandHandlers/MoveToAccept/MoveToAcceptCommandHandler.cs +++ b/src/Inc.TeamAssistant.Reviewer.Application/CommandHandlers/MoveToAccept/MoveToAcceptCommandHandler.cs @@ -42,7 +42,7 @@ public async Task Handle(MoveToAcceptCommand command, Cancellatio if (owner is null) throw new TeamAssistantUserException(Messages.Connector_PersonNotFound, taskForReview.OwnerId); - taskForReview.Accept(DateTimeOffset.UtcNow, command.AcceptedWithComments); + taskForReview.Accept(DateTimeOffset.UtcNow, command.HasComments); var notifications = await _reviewMessageBuilder.Build( command.MessageContext.ChatMessage.MessageId, diff --git a/src/Inc.TeamAssistant.Reviewer.Application/Services/ReviewMessageBuilder.cs b/src/Inc.TeamAssistant.Reviewer.Application/Services/ReviewMessageBuilder.cs index 82b1e653..f8cb92e3 100644 --- a/src/Inc.TeamAssistant.Reviewer.Application/Services/ReviewMessageBuilder.cs +++ b/src/Inc.TeamAssistant.Reviewer.Application/Services/ReviewMessageBuilder.cs @@ -388,11 +388,12 @@ private async Task ReviewFinish(TaskForReview task, Cancell var languageId = await _teamAccessor.GetClientLanguage(task.BotId, task.OwnerId, token); var totalTime = task.GetTotalTime(DateTimeOffset.UtcNow); + var stateMessage = task.State == TaskForReviewState.AcceptWithComments + ? Messages.Reviewer_AcceptedWithComments + : Messages.Reviewer_Accepted; var builder = new StringBuilder(); - builder.AppendLine(await _messageBuilder.Build( - task.AcceptedWithComments ? Messages.Reviewer_AcceptedWithComments : Messages.Reviewer_Accepted, - languageId)); + builder.AppendLine(await _messageBuilder.Build(stateMessage, languageId)); builder.AppendLine(); builder.AppendLine(task.Description); builder.AppendLine(); @@ -412,6 +413,7 @@ private string StateAsIcon(TaskForReview task) TaskForReviewState.InProgress => Icons.InProgress, TaskForReviewState.OnCorrection => Icons.OnCorrection, TaskForReviewState.Accept => Icons.Accept, + TaskForReviewState.AcceptWithComments => Icons.AcceptWithComments, _ => throw new ArgumentOutOfRangeException(nameof(task.State), task.State, "State out of range.") }; } diff --git a/src/Inc.TeamAssistant.Reviewer.DataAccess/TaskForReviewRepository.cs b/src/Inc.TeamAssistant.Reviewer.DataAccess/TaskForReviewRepository.cs index 48ea8c6b..b011f52e 100644 --- a/src/Inc.TeamAssistant.Reviewer.DataAccess/TaskForReviewRepository.cs +++ b/src/Inc.TeamAssistant.Reviewer.DataAccess/TaskForReviewRepository.cs @@ -41,8 +41,7 @@ public async Task> Get( t.message_id AS messageid, t.chat_id AS chatid, t.original_reviewer_id AS originalreviewerid, - t.review_intervals AS reviewintervals, - t.accepted_with_comments AS acceptedwithcomments + t.review_intervals AS reviewintervals FROM review.task_for_reviews AS t WHERE t.team_id = @team_id AND t.state = ANY(@states);", new @@ -80,8 +79,7 @@ public async Task GetById(Guid taskForReviewId, CancellationToken t.message_id AS messageid, t.chat_id AS chatid, t.original_reviewer_id AS originalreviewerid, - t.review_intervals AS reviewintervals, - t.accepted_with_comments AS acceptedwithcomments + t.review_intervals AS reviewintervals FROM review.task_for_reviews AS t WHERE t.id = @id;", new { id = taskForReviewId }, @@ -117,8 +115,7 @@ INSERT INTO review.task_for_reviews ( message_id, chat_id, original_reviewer_id, - review_intervals, - accepted_with_comments) + review_intervals) VALUES ( @id, @bot_id, @@ -136,8 +133,7 @@ INSERT INTO review.task_for_reviews ( @message_id, @chat_id, @original_reviewer_id, - @review_intervals::jsonb, - @accepted_with_comments) + @review_intervals::jsonb) ON CONFLICT (id) DO UPDATE SET bot_id = excluded.bot_id, team_id = excluded.team_id, @@ -154,8 +150,7 @@ ON CONFLICT (id) DO UPDATE SET message_id = excluded.message_id, chat_id = excluded.chat_id, original_reviewer_id = excluded.original_reviewer_id, - review_intervals = excluded.review_intervals, - accepted_with_comments = excluded.accepted_with_comments;", + review_intervals = excluded.review_intervals;", new { id = taskForReview.Id, @@ -174,8 +169,7 @@ ON CONFLICT (id) DO UPDATE SET reviewer_id = taskForReview.ReviewerId, reviewer_message_id = taskForReview.ReviewerMessageId, original_reviewer_id = taskForReview.OriginalReviewerId, - review_intervals = reviewIntervals, - accepted_with_comments = taskForReview.AcceptedWithComments + review_intervals = reviewIntervals }, flags: CommandFlags.None, cancellationToken: token); diff --git a/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReview.cs b/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReview.cs index ad478fcf..71039f64 100644 --- a/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReview.cs +++ b/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReview.cs @@ -19,7 +19,6 @@ public sealed class TaskForReview : ITaskForReviewStats public int? MessageId { get; private set; } public long? OriginalReviewerId { get; private set; } public IReadOnlyCollection ReviewIntervals { get; private set; } - public bool AcceptedWithComments { get; private set; } private TaskForReview() { @@ -80,19 +79,14 @@ public void SetNextNotificationTime(DateTimeOffset now, NotificationIntervals no public bool CanAccept() => TaskForReviewStateRules.ActiveStates.Contains(State); - public void Accept(DateTimeOffset now, bool acceptedWithComments) + public void Accept(DateTimeOffset now, bool hasComments) { AddReviewInterval(ReviewerId, now); AcceptDate = now; - - if (acceptedWithComments) - { - MoveToAcceptWithComments(); - return; - } - - MoveToAccept(); + State = hasComments + ? TaskForReviewState.AcceptWithComments + : TaskForReviewState.Accept; } public void MoveToAccept() => State = TaskForReviewState.Accept; @@ -162,10 +156,4 @@ private void SetReviewer(long reviewerId) ReviewerId = reviewerId; } - - private void MoveToAcceptWithComments() - { - State = TaskForReviewState.Accept; - AcceptedWithComments = true; - } } \ No newline at end of file diff --git a/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReviewState.cs b/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReviewState.cs index 86f672e4..a70f4985 100644 --- a/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReviewState.cs +++ b/src/Inc.TeamAssistant.Reviewer.Domain/TaskForReviewState.cs @@ -5,5 +5,6 @@ public enum TaskForReviewState New = 1, InProgress = 2, OnCorrection = 3, - Accept = 4 + Accept = 4, + AcceptWithComments = 5 } \ No newline at end of file diff --git a/src/Inc.TeamAssistant.Reviewer.Model/Commands/MoveToAccept/MoveToAcceptCommand.cs b/src/Inc.TeamAssistant.Reviewer.Model/Commands/MoveToAccept/MoveToAcceptCommand.cs index a0cbe61d..9d646f73 100644 --- a/src/Inc.TeamAssistant.Reviewer.Model/Commands/MoveToAccept/MoveToAcceptCommand.cs +++ b/src/Inc.TeamAssistant.Reviewer.Model/Commands/MoveToAccept/MoveToAcceptCommand.cs @@ -2,5 +2,5 @@ namespace Inc.TeamAssistant.Reviewer.Model.Commands.MoveToAccept; -public sealed record MoveToAcceptCommand(MessageContext MessageContext, Guid TaskId, bool AcceptedWithComments) +public sealed record MoveToAcceptCommand(MessageContext MessageContext, Guid TaskId, bool HasComments) : IDialogCommand; \ No newline at end of file diff --git a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.Designer.cs b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.Designer.cs index 9ba560c0..5bf2014b 100644 --- a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.Designer.cs +++ b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.Designer.cs @@ -464,5 +464,11 @@ internal static string TeamField { return ResourceManager.GetString("TeamField", resourceCulture); } } + + internal static string ReviewStateAcceptWithComments { + get { + return ResourceManager.GetString("ReviewStateAcceptWithComments", resourceCulture); + } + } } } diff --git a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.resx b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.resx index 62f74a79..d0692048 100644 --- a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.resx +++ b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.resx @@ -228,4 +228,7 @@ Team + + Accept with comments + \ No newline at end of file diff --git a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.Designer.cs b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.Designer.cs index 629b1030..8ddaae65 100644 --- a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.Designer.cs +++ b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.Designer.cs @@ -464,5 +464,11 @@ internal static string TeamField { return ResourceManager.GetString("TeamField", resourceCulture); } } + + internal static string ReviewStateAcceptWithComments { + get { + return ResourceManager.GetString("ReviewStateAcceptWithComments", resourceCulture); + } + } } } diff --git a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.resx b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.resx index 47ad031a..409b2fcf 100644 --- a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.resx +++ b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/DashboardResources.ru.resx @@ -228,4 +228,7 @@ Команда + + Принята с коментариями + \ No newline at end of file diff --git a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/Reviewer/ReviewHistoryWidget.razor b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/Reviewer/ReviewHistoryWidget.razor index 5d040830..dff2c7c2 100644 --- a/src/Inc.TeamAssistant.WebUI/Features/Dashboard/Reviewer/ReviewHistoryWidget.razor +++ b/src/Inc.TeamAssistant.WebUI/Features/Dashboard/Reviewer/ReviewHistoryWidget.razor @@ -120,7 +120,8 @@ ["New"] = Localizer["ReviewStateNew"], ["InProgress"] = Localizer["ReviewStateInProgress"], ["OnCorrection"] = Localizer["ReviewStateOnCorrection"], - ["Accept"] = Localizer["ReviewStateAccept"] + ["Accept"] = Localizer["ReviewStateAccept"], + ["AcceptWithComments"] = Localizer["ReviewStateAcceptWithComments"] }; private IQueryable Tasks => Items.AsQueryable();