-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Field HasConcreteReviewer was removed from TaskForReview
- Loading branch information
Showing
26 changed files
with
315 additions
and
188 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/Inc.TeamAssistant.Migrations/2024_12_09_0_ChangeReviewer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using FluentMigrator; | ||
|
||
namespace Inc.TeamAssistant.Migrations; | ||
|
||
[Migration(2024_12_09_0)] | ||
public sealed class ChangeReviewer : Migration | ||
{ | ||
public override void Up() | ||
{ | ||
Execute.Sql( | ||
""" | ||
UPDATE review.task_for_reviews AS t | ||
SET strategy = 3 | ||
WHERE t.has_concrete_reviewer | ||
""", | ||
"Set strategy by has_concrete_reviewer"); | ||
|
||
Delete | ||
.Column("has_concrete_reviewer") | ||
.FromTable("task_for_reviews") | ||
.InSchema("review"); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
Create | ||
.Column("has_concrete_reviewer") | ||
.OnTable("task_for_reviews") | ||
.InSchema("review") | ||
.AsBoolean() | ||
.NotNullable() | ||
.SetExistingRowsTo(false); | ||
|
||
Execute.Sql( | ||
""" | ||
UPDATE review.task_for_reviews AS t | ||
SET has_concrete_reviewer = t.strategy = 3; | ||
""", | ||
"Set has_concrete_reviewer by strategy"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Inc.TeamAssistant.Reviewer.Application/Services/NextReviewerStrategyFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Inc.TeamAssistant.Holidays.Extensions; | ||
using Inc.TeamAssistant.Primitives.Exceptions; | ||
using Inc.TeamAssistant.Reviewer.Application.Contracts; | ||
using Inc.TeamAssistant.Reviewer.Domain; | ||
using Inc.TeamAssistant.Reviewer.Domain.NextReviewerStrategies; | ||
|
||
namespace Inc.TeamAssistant.Reviewer.Application.Services; | ||
|
||
internal sealed class NextReviewerStrategyFactory : INextReviewerStrategyFactory | ||
{ | ||
private readonly ITaskForReviewReader _taskForReviewReader; | ||
private readonly ITaskForReviewRepository _taskForReviewRepository; | ||
|
||
public NextReviewerStrategyFactory( | ||
ITaskForReviewReader taskForReviewReader, | ||
ITaskForReviewRepository taskForReviewRepository) | ||
{ | ||
_taskForReviewReader = taskForReviewReader ?? throw new ArgumentNullException(nameof(taskForReviewReader)); | ||
_taskForReviewRepository = | ||
taskForReviewRepository ?? throw new ArgumentNullException(nameof(taskForReviewRepository)); | ||
} | ||
|
||
public async Task<INextReviewerStrategy> Create( | ||
Guid teamId, | ||
long ownerId, | ||
NextReviewerType nextReviewerType, | ||
long? targetPersonId, | ||
IReadOnlyCollection<long> teammates, | ||
long? excludePersonId, | ||
CancellationToken token) | ||
{ | ||
ArgumentNullException.ThrowIfNull(teammates); | ||
|
||
var lastReviewerId = await _taskForReviewRepository.FindLastReviewer( | ||
teamId, | ||
ownerId, | ||
token); | ||
var history = await _taskForReviewReader.GetHistory( | ||
teamId, | ||
DateTimeOffset.UtcNow.GetLastDayOfWeek(DayOfWeek.Monday), | ||
token); | ||
|
||
var excludedPersonIds = excludePersonId.HasValue | ||
? new[] { ownerId, excludePersonId.Value } | ||
: [ownerId]; | ||
|
||
return nextReviewerType switch | ||
{ | ||
NextReviewerType.RoundRobin => new RoundRobinReviewerStrategy(teammates, excludedPersonIds, lastReviewerId), | ||
NextReviewerType.Random => new RandomReviewerStrategy(teammates, history, excludedPersonIds, lastReviewerId), | ||
NextReviewerType.Target when targetPersonId.HasValue => new TargetReviewerStrategy(targetPersonId.Value), | ||
_ => throw new TeamAssistantException($"NextReviewerType {nextReviewerType} was not supported.") | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.