Skip to content

Commit

Permalink
Field AcceptWithComments was removed from TaskForReview
Browse files Browse the repository at this point in the history
  • Loading branch information
dyatlov-a committed Dec 10, 2024
1 parent a7a8a2a commit 3f4a611
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 35 deletions.
44 changes: 44 additions & 0 deletions src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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");
}
}
1 change: 1 addition & 0 deletions src/Inc.TeamAssistant.Primitives/Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "👌";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task<CommandResult> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,12 @@ private async Task<NotificationMessage> 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();
Expand All @@ -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.")
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public async Task<IReadOnlyCollection<TaskForReview>> 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
Expand Down Expand Up @@ -80,8 +79,7 @@ public async Task<TaskForReview> 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 },
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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);
Expand Down
20 changes: 4 additions & 16 deletions src/Inc.TeamAssistant.Reviewer.Domain/TaskForReview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public sealed class TaskForReview : ITaskForReviewStats
public int? MessageId { get; private set; }
public long? OriginalReviewerId { get; private set; }
public IReadOnlyCollection<ReviewInterval> ReviewIntervals { get; private set; }
public bool AcceptedWithComments { get; private set; }

private TaskForReview()
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -162,10 +156,4 @@ private void SetReviewer(long reviewerId)

ReviewerId = reviewerId;
}

private void MoveToAcceptWithComments()
{
State = TaskForReviewState.Accept;
AcceptedWithComments = true;
}
}
3 changes: 2 additions & 1 deletion src/Inc.TeamAssistant.Reviewer.Domain/TaskForReviewState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public enum TaskForReviewState
New = 1,
InProgress = 2,
OnCorrection = 3,
Accept = 4
Accept = 4,
AcceptWithComments = 5
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,7 @@
<data name="TeamField" xml:space="preserve">
<value>Team</value>
</data>
<data name="ReviewStateAcceptWithComments" xml:space="preserve">
<value>Accept with comments</value>
</data>
</root>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,7 @@
<data name="TeamField" xml:space="preserve">
<value>Команда</value>
</data>
<data name="ReviewStateAcceptWithComments" xml:space="preserve">
<value>Принята с коментариями</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
["New"] = Localizer["ReviewStateNew"],
["InProgress"] = Localizer["ReviewStateInProgress"],
["OnCorrection"] = Localizer["ReviewStateOnCorrection"],
["Accept"] = Localizer["ReviewStateAccept"]
["Accept"] = Localizer["ReviewStateAccept"],
["AcceptWithComments"] = Localizer["ReviewStateAcceptWithComments"]
};
private IQueryable<TaskForReviewDto> Tasks => Items.AsQueryable();

Expand Down

0 comments on commit 3f4a611

Please sign in to comment.