Skip to content

Commit 8489e76

Browse files
authored
Поправлен баг с письмом о закрытии (#2839)
* И еще раз были проблемы с форматированием сообщений * Добавить GlobalUsings в Services.Impl.Test * Тесты на staledatecalculator * Улучшены логи * Убрать неиспользуемую переменную
1 parent 535d6d1 commit 8489e76

File tree

7 files changed

+82
-9
lines changed

7 files changed

+82
-9
lines changed

.editorconfig

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dotnet_style_qualification_for_event = false:warning
9191
csharp_prefer_braces = true:warning
9292

9393
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
94-
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
94+
csharp_style_unused_value_assignment_preference = discard_variable:warning
9595

9696
dotnet_sort_system_directives_first = true
9797

@@ -107,6 +107,32 @@ csharp_style_expression_bodied_operators = false:silent
107107
csharp_style_expression_bodied_indexers = true:silent
108108
csharp_style_throw_expression = true:suggestion
109109
csharp_style_prefer_null_check_over_type_check = true:suggestion
110+
csharp_style_prefer_method_group_conversion = true:silent
111+
csharp_style_prefer_top_level_statements = true:silent
112+
csharp_style_prefer_primary_constructors = true:suggestion
113+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
114+
csharp_prefer_simple_default_expression = true:suggestion
115+
csharp_style_prefer_index_operator = true:suggestion
116+
csharp_style_prefer_range_operator = true:suggestion
117+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
118+
csharp_style_prefer_tuple_swap = true:suggestion
119+
csharp_style_prefer_utf8_string_literals = true:suggestion
120+
csharp_style_inlined_variable_declaration = true:suggestion
121+
csharp_style_deconstructed_variable_declaration = true:suggestion
122+
csharp_prefer_static_local_function = true:suggestion
123+
csharp_style_prefer_readonly_struct = true:suggestion
124+
csharp_prefer_static_anonymous_function = true:suggestion
125+
csharp_style_prefer_readonly_struct_member = true:suggestion
126+
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
127+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
128+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
129+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
130+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
131+
csharp_style_prefer_switch_expression = true:suggestion
132+
csharp_style_prefer_pattern_matching = true:silent
133+
csharp_style_prefer_not_pattern = true:suggestion
134+
csharp_style_prefer_extended_property_pattern = true:suggestion
135+
csharp_style_var_elsewhere = false:silent
110136

111137

112138
[*.{cs,vb}]
@@ -159,3 +185,21 @@ dotnet_naming_style.pascal_case.capitalization = pascal_case
159185

160186
# Default severity for analyzer diagnostics with category 'GeneratedRegex'
161187
dotnet_analyzer_diagnostic.category-GeneratedRegex.severity = warning
188+
189+
190+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
191+
dotnet_style_readonly_field = true:suggestion
192+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
193+
dotnet_style_predefined_type_for_member_access = true:warning
194+
dotnet_style_require_accessibility_modifiers = always:warning
195+
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
196+
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
197+
dotnet_code_quality_unused_parameters = all:suggestion
198+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
199+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
200+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
201+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
202+
dotnet_style_qualification_for_field = false:warning
203+
dotnet_style_qualification_for_property = false:warning
204+
dotnet_style_qualification_for_method = false:warning
205+
dotnet_style_qualification_for_event = false:warning

src/JoinRpg.Services.Email/MasterEmailServiceImpl.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public async Task EmailProjectStale(ProjectStaleMail email)
2727

2828
var body = $@"Добрый день, {messageService.GetRecepientPlaceholderName()}
2929
30-
Проект {metadata.ProjectName} был в последний раз активен {email.LastActiveDate:YYYY-MM-dd}. Если до {email.WillCloseDate:YYYY-MM-dd} активность в нем не появится, он автоматически будет закрыт.
30+
Проект {metadata.ProjectName} был в последний раз активен {email.LastActiveDate:yyyy-MM-dd}. Если до {email.WillCloseDate:yyyy-MM-dd} активность в нем не появится, он автоматически будет закрыт.
31+
32+
Подробности в справке https://docs.joinrpg.ru/ru/latest/project/after.html#id3
3133
3234
Не переживайте, закрытый проект всегда можно будет посмотреть, он не пропадет. Если проект завершен или больше не нужен, вы можете закрыть его сами.
3335
@@ -74,7 +76,7 @@ async Task IMasterEmailService.EmailProjectClosedStale(ProjectClosedStaleMail em
7476

7577
var body = $@"Добрый день, {messageService.GetRecepientPlaceholderName()}
7678
77-
Проект {metadata.ProjectName} был закрыт, т.к. он не был активен с {email.LastActiveDate:YYYY-MM-dd}. Вы всегда можете найти его по ссылке {uriService.GetUri(email.ProjectId)}
79+
Проект {metadata.ProjectName} был закрыт, т.к. он не был активен с {email.LastActiveDate:yyyy-MM-dd}. Вы всегда можете найти его по ссылке {uriService.GetUri(email.ProjectId)}
7880
7981
--
8082
{joinRpgSender.DisplayName}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
global using Shouldly;
2+
global using Xunit;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using JoinRpg.Services.Impl.Projects;
2+
3+
namespace JoinRpg.Services.Impl.Test;
4+
public class ProjectStaleDateCalculatorTests
5+
{
6+
[Fact]
7+
public void InFutureShouldBeSixMonthLater()
8+
{
9+
var lastUpdated = new DateOnly(2025, 1, 1);
10+
ProjectStaleDateCalculator.CalculateCloseDate(lastUpdated).ShouldBe(new DateOnly(2025, 8, 1));
11+
}
12+
13+
[Fact]
14+
public void ShouldBeAfterNovebmer2024()
15+
{
16+
var lastUpdated = new DateOnly(2021, 1, 1);
17+
ProjectStaleDateCalculator.CalculateCloseDate(lastUpdated).ShouldBe(new DateOnly(2024, 11, 1));
18+
}
19+
20+
[Fact]
21+
public void Scrackanobaza()
22+
{
23+
var lastUpdated = new DateOnly(2024, 7, 16);
24+
ProjectStaleDateCalculator.CalculateCloseDate(lastUpdated).ShouldBe(new DateOnly(2025, 2, 16));
25+
}
26+
}

src/JoinRpg.Services.Impl.Test/SearchKeywordsResolverTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using JoinRpg.Services.Impl.Search;
2-
using Shouldly;
3-
using Xunit;
42

53
namespace JoinRpg.Services.Impl.Test;
64

src/JoinRpg.Services.Impl/Projects/ProjectPerformCloseJob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task RunOnce(CancellationToken cancellationToken)
2323
}
2424
else
2525
{
26-
logger.LogInformation("Project {project} is stale since {staleDate}. It will be closed now .", staleProject.ProjectId, lastUpdateDate);
26+
logger.LogInformation("Project {project} is stale since {staleDate}. It will be closed now.", staleProject.ProjectId, lastUpdateDate);
2727
}
2828

2929
await projectService.CloseProjectAsStale(new(staleProject.ProjectId), lastUpdateDate);

src/JoinRpg.Services.Impl/Projects/ProjectWarnCloseJob.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ public async Task RunOnce(CancellationToken cancellationToken)
1515
{
1616
if (staleProject.LastUpdated.Day != today.Day)
1717
{
18-
logger.LogInformation("Project {project} is stale. It will be warned on {dayOfMonth} day of month", staleProject.ProjectId, staleProject.LastUpdated.Day);
18+
logger.LogInformation("Project {project} is stale since {staleDate}. It will be warned on {dayOfMonth} day of month",
19+
staleProject.ProjectId,
20+
staleProject.LastUpdated,
21+
staleProject.LastUpdated.Day);
1922
continue;
2023
}
2124

22-
var project = await projectRepository.GetProjectAsync(staleProject.ProjectId);
23-
2425
var lastUpdateDate = DateOnly.FromDateTime(staleProject.LastUpdated);
2526
var email = new ProjectStaleMail()
2627
{

0 commit comments

Comments
 (0)