Skip to content

Котлярский Вадим Лаб. 1 Группа 6512#51

Open
K0tlyarski wants to merge 2 commits intoitsecd:mainfrom
K0tlyarski:main
Open

Котлярский Вадим Лаб. 1 Группа 6512#51
K0tlyarski wants to merge 2 commits intoitsecd:mainfrom
K0tlyarski:main

Conversation

@K0tlyarski
Copy link

ФИО: Котлярский Вадим
Номер группы: 6512
Номер лабораторной: 1
Номер варианта: 24
Краткое описание предметной области: Медицинский пациент.
Краткое описание добавленных фич: Добавлена модель данных, добавлен сервис генерации, сделан endpoint, добавлен кеш, оркестратор

@github-actions github-actions bot added In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование labels Mar 13, 2026
@github-actions github-actions bot requested a review from Gwymlas March 13, 2026 18:56
Copy link

Choose a reason for hiding this comment

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

Удалить служебные файлы IDE, добавить .idea в .gitignore

Comment on lines +105 to +133
if (node is null)
{
return "нет данных";
}

if (node is JsonValue value)
{
if (value.TryGetValue<bool>(out var boolValue))
{
return boolValue ? "Да" : "Нет";
}

if (value.TryGetValue<double>(out var doubleValue))
{
return doubleValue.ToString("0.00");
}

if (value.TryGetValue<int>(out var intValue))
{
return intValue.ToString();
}

if (value.TryGetValue<string>(out var stringValue))
{
return stringValue;
}
}

return node.ToJsonString();
Copy link

Choose a reason for hiding this comment

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

Можно что то такое:

return node switch
{
    null => "нет данных",
    JsonValue value when value.TryGetValue<bool>(out var boolValue) => boolValue ? "Да" : "Нет",
    JsonValue value when value.TryGetValue<double>(out var doubleValue) => doubleValue.ToString("0.00"),
    JsonValue value when value.TryGetValue<int>(out var intValue) => intValue.ToString(),
    JsonValue value when value.TryGetValue<string>(out var stringValue) => stringValue,
    _ => node.ToJsonString()
};

Comment on lines +117 to +125
if (value.TryGetValue<double>(out var doubleValue))
{
return doubleValue.ToString("0.00");
}

if (value.TryGetValue<int>(out var intValue))
{
return intValue.ToString();
}
Copy link

Choose a reason for hiding this comment

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

Проверяем на int раньше double, иначе получаем такое

Image

<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
Copy link

Choose a reason for hiding this comment

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

Ссылка на форк потерялась

var gender = faker.PickRandom<Name.Gender>();
var lastName = faker.Name.LastName(gender);
var firstName = faker.Name.FirstName(gender);
var patronymicBase = faker.Name.FirstName(gender);
Copy link

Choose a reason for hiding this comment

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

Для отчества всегда за основу берется мужское имя

Image

Comment on lines +58 to +74
private static T PickWeighted<T>(Faker faker, params (T value, int weight)[] items)
{
var totalWeight = items.Sum(item => item.weight);
var roll = faker.Random.Int(1, totalWeight);
var currentWeight = 0;

foreach (var item in items)
{
currentWeight += item.weight;
if (roll <= currentWeight)
{
return item.value;
}
}

return items[^1].value;
}
Copy link

Choose a reason for hiding this comment

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

В Bogus есть похожая реализация

Comment on lines +47 to +55
var birthDateTime = birthDate.ToDateTime(TimeOnly.MinValue);
var today = DateTime.Today;

if (birthDateTime >= today)
{
return birthDate;
}

return DateOnly.FromDateTime(faker.Date.Between(birthDateTime, today));
Copy link

Choose a reason for hiding this comment

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

Есть BetweenDateOnly
Тогда получится:

var today = DateOnly.FromDateTime(DateTime.Today);
return birthDate >= today ? birthDate : faker.Date.BetweenDateOnly(birthDate, today);

});
});

builder.Services.AddScoped<MedicalPatientGenerator>();
Copy link

Choose a reason for hiding this comment

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

MedicalPatientGenerator можно зарегистрировать как Singleton

.WaitFor(redis);

builder.AddProject<Projects.Client_Wasm>("client")
.WithReference(api)
Copy link

Choose a reason for hiding this comment

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

.WithReference(api) не нужен

Comment on lines +16 to +17
[HttpGet]
public async Task<ActionResult<MedicalPatient>> GetById([FromQuery] int id, CancellationToken cancellationToken)
Copy link

Choose a reason for hiding this comment

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

Добавить атрибут ProducesResponseType

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.

2 participants