Skip to content

Челаев Петр Лаб. 1 Группа 6512#14

Open
PripyatskyPrometheus wants to merge 12 commits intoitsecd:mainfrom
PripyatskyPrometheus:main
Open

Челаев Петр Лаб. 1 Группа 6512#14
PripyatskyPrometheus wants to merge 12 commits intoitsecd:mainfrom
PripyatskyPrometheus:main

Conversation

@PripyatskyPrometheus
Copy link

ФИО: Челаев Петр
Номер группы: 6512
Номер лабораторной: 1
Номер варианта: 35
Краткое описание предметной области: Программный проект
Краткое описание добавленных фич: Добавлен сервис генерации и кэширование

@github-actions github-actions bot added In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование labels Feb 23, 2026
@alxmcs alxmcs closed this Feb 24, 2026
@alxmcs alxmcs reopened this Feb 24, 2026
@github-actions github-actions bot requested a review from Gwymlas February 24, 2026 07:52
@@ -0,0 +1,15 @@
var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("cache");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

К редису добавить контейнер с вебмордой

.WithReference(cache)
.WaitFor(cache);

// ������� �������
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проблемы с кодировкой

// ������� �������
var client = builder.AddProject<Projects.Client_Wasm>("client-wasm")
.WithExternalHttpEndpoints()
.WithReference(generationService);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Точно надо .WithReference(generationService)?
Я бы добавил .WaitFor(generationService)

Comment on lines 20 to 21
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.1" />
<PackageReference Include="Aspire.Hosting.Redis" Version="13.1.1" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разные версии Aspire Sdk и пакетов

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Извините, вот этого замечания не понял? Какие пакеты версии разные? Наоборот они вроде одни и те же

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выше в этом файле
<Sdk Name="Aspire.AppHost.Sdk" Version="9.3.1" />

Давай остановимся на версии 9.5.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

<ItemGroup>
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
<ProjectReference Include="..\ProgramProject.GenerationService\ProgramProject.GenerationService.csproj" />
<ProjectReference Include="..\ProgramProject.ServiceDefaults\ProgramProject.ServiceDefaults.csproj" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ненужная ссылка на проект

Comment on lines 26 to 27
var uri = new Uri(origin);
return uri.Host == "localhost";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю лучше обернуть в try-catch

var uri = new Uri(origin);
return uri.Host == "localhost";
})
.AllowAnyMethod()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно разрешить только GET запросы

Comment on lines 19 to 25
f.PickRandom(new[]
{
f.Commerce.ProductName() + " " + f.Hacker.Abbreviation(),
"Project " + f.Hacker.Noun(),
f.Finance.AccountName() + " System",
f.Lorem.Word() + "-" + f.Lorem.Word()
}))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f.PickRandom(
    f.Commerce.ProductName() + " " + f.Hacker.Abbreviation(), 
    "Project " + f.Hacker.Noun(), 
    f.Finance.AccountName() + " System", 
    f.Lorem.Word() + "-" + f.Lorem.Word()
))

Comment on lines 15 to 18
/// <summary>
/// Название проекта: комбинация из Commerce, Hacker, Finance, Lorem
/// </summary>
.RuleFor(p => p.Name, f =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут и в других местах используй по необходимости однострочные комментарии (//) для пояснения логики кода
XML-комментарии используй для документирования классов и методов, а не внутренней реализации

Comment on lines 87 to 93
.FinishWith((f, p) =>
{
if (p.ActualEndDate.HasValue)
{
p.CompletionPercentage = 100;
}
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот код не избыточен?

Copy link

@Gwymlas Gwymlas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Общее замечание: пробежаться по коду и добавить summary к классам и методам, где необходимо

.WithReference(cache)
.WaitFor(cache);


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишняя пустая строка

// Бюджет: от 10k до 1M
.RuleFor(p => p.Budget, f => f.Finance.Amount(10000, 1000000, 2))


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишняя пустая строка

_faker = faker;
_logger = logger;

var cacheMinutes = configuration.GetValue<int>("Cache:ExpirationMinutes", 5);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<int> не нужен, тип определяется по дефолтному значению

Comment on lines 11 to 12
[HttpGet("{id}")]
public async Task<ActionResult<ProgramProjectModel>> GetProject(int id)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавить атрибуты с возвращаемыми типами

[ApiController]
public class ProjectsController(IProjectService projectService, ILogger<ProjectsController> logger) : ControllerBase
{
[HttpGet("{id}")]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавить ограничение типа параметра
[HttpGet("{id:int}")]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставить только 1 метод, который используется фронтом

public ProgramProjectModel Generate()
{
return _faker.Generate();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно так

public ProgramProjectModel Generate() => 
        _faker.Generate();

Comment on lines +41 to +43
var cachedProject = JsonSerializer.Deserialize<ProgramProjectModel>(cachedBytes);
_logger.LogInformation("Проект с ID {ProjectId} найден в кэше", id);
return cachedProject!;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможна ситуация, при которой в кэше будет null. Лучше проверить значение, если null, сгенерировать новый объект

});
});

builder.Services.AddSingleton<ProgramProjectFaker>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выделить интерфейс и регистрировать в di через него

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="13.1.1" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправить версию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants