Skip to content

Comments

[4115] Фильтрация кабинетов#101

Open
taaylor wants to merge 1 commit intostagingfrom
feat/classroom-filtering
Open

[4115] Фильтрация кабинетов#101
taaylor wants to merge 1 commit intostagingfrom
feat/classroom-filtering

Conversation

@taaylor
Copy link
Member

@taaylor taaylor commented Dec 23, 2025

@taaylor taaylor requested a review from niqzart December 23, 2025 10:08
@taaylor taaylor closed this Dec 23, 2025
@taaylor taaylor deleted the feat/classroom-filtering branch December 23, 2025 10:22
@taaylor taaylor restored the feat/classroom-filtering branch December 23, 2025 10:23
@taaylor taaylor reopened this Dec 23, 2025
@taaylor taaylor changed the title Фильтрация кабинетов [4115] Фильтрация кабинетов Dec 23, 2025
@taaylor taaylor assigned taaylor and unassigned taaylor Dec 23, 2025
@taaylor taaylor force-pushed the feat/classroom-filtering branch from a563d55 to 4520c4e Compare December 23, 2025 10:28
@taaylor taaylor changed the base branch from main to staging December 23, 2025 10:29
@taaylor taaylor self-assigned this Dec 23, 2025
@taaylor taaylor added ci:covered If coverage checks should be run on the PR ci:migrated If migration checks should be run on the PR labels Dec 23, 2025
Comment on lines +46 to +71
kind = CLASSROOMS_KINDS[
i // (CLASSROOMS_LIST_SIZE // 2) % len(CLASSROOMS_KINDS)
]
match kind:
case ClassroomKind.INDIVIDUAL:
yield await IndividualClassroom.create(
**factories.IndividualClassroomInputFactory.build_python(
subject_id=CLASSROOMS_SUBJECT_IDS[
i % len(CLASSROOMS_SUBJECT_IDS)
],
),
status=CLASSROOMS_STATUSES[i % len(CLASSROOMS_STATUSES)],
tutor_id=tutor_user_id,
student_id=tutor_user_id + i + 1,
tutor_name=faker.name(),
student_name=faker.name(),
created_at=last_created_at,
)
case ClassroomKind.GROUP:
yield await GroupClassroom.create(
**factories.GroupClassroomInputFactory.build_python(
subject_id=CLASSROOMS_SUBJECT_IDS[
i % len(CLASSROOMS_SUBJECT_IDS)
],
),
status=CLASSROOMS_STATUSES[i % len(CLASSROOMS_STATUSES)],
Copy link
Member

@niqzart niqzart Jan 10, 2026

Choose a reason for hiding this comment

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

issue(repeat)(repeat): генерация данных неверная, полное покрытие не создаётся https://discord.com/channels/706806130348785715/1423620574089052244/1439681556489834778

Comment on lines +128 to +139
classroom_requests_parametrization = pytest.mark.parametrize(
("offset", "limit"),
[
pytest.param(None, CLASSROOMS_LIST_SIZE, id="start_to_end"),
pytest.param(None, CLASSROOMS_LIST_SIZE // 2, id="start_to_middle"),
pytest.param(
CLASSROOMS_LIST_SIZE // 2,
CLASSROOMS_LIST_SIZE,
id="middle_to_end",
),
],
)
Copy link
Member

Choose a reason for hiding this comment

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

polish: некорректный порядок (создавать надо прямо перед первым использованием, не в рандомном месте файла)

Comment on lines +175 to +177
(None, {ClassroomKind.INDIVIDUAL.value}),
(None, {ClassroomStatus.ACTIVE.value}),
(None, {CLASSROOMS_SUBJECT_IDS[0]}),
Copy link
Member

Choose a reason for hiding this comment

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

issue(repeat): хардкод, не рандом

Comment on lines +180 to +192
pytest.param(None, set(CLASSROOMS_STATUSES[:2]), None, id="multiple_statuses"),
pytest.param(set(CLASSROOMS_KINDS[:2]), None, None, id="multiple_kinds"),
pytest.param(
None, None, set(CLASSROOMS_SUBJECT_IDS[:2]), id="multiple_subject_ids"
),
pytest.param(set(CLASSROOMS_KINDS), None, None, id="all_kinds"),
pytest.param(None, set(CLASSROOMS_STATUSES), None, id="all_statuses"),
pytest.param(
set(CLASSROOMS_KINDS),
set(CLASSROOMS_STATUSES),
set(CLASSROOMS_SUBJECT_IDS[:2]),
id="all_filter",
),
Copy link
Member

Choose a reason for hiding this comment

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

issue(repeat): тоже хардкод, не рандом

Copy link
Member

Choose a reason for hiding this comment

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

Проще будет сделать это отдельным тестом, тогда и рандомизация получится внутри теста (как и должно быть), и параметризация будет не такая страшная

Comment on lines +188 to +191
set(CLASSROOMS_KINDS),
set(CLASSROOMS_STATUSES),
set(CLASSROOMS_SUBJECT_IDS[:2]),
id="all_filter",
Copy link
Member

Choose a reason for hiding this comment

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

issue: это не фильтр всего и это не так переводится на английский

Comment on lines +253 to +290
kind = CLASSROOMS_KINDS[
i
// (CLASSROOMS_LIST_SIZE // len(CLASSROOMS_KINDS))
% len(CLASSROOMS_KINDS)
]
match kind:
case ClassroomKind.INDIVIDUAL:
yield await IndividualClassroom.create(
**factories.IndividualClassroomInputFactory.build_python(
subject_id=CLASSROOMS_SUBJECT_IDS[
(i // len(CLASSROOMS_STATUSES))
% len(CLASSROOMS_SUBJECT_IDS)
],
),
status=CLASSROOMS_STATUSES[i % len(CLASSROOMS_STATUSES)],
tutor_id=student_user_id + i + 1,
student_id=student_user_id,
tutor_name=faker.name(),
student_name=faker.name(),
created_at=last_created_at,
)
case ClassroomKind.GROUP:
group_classroom = await GroupClassroom.create(
**factories.GroupClassroomInputFactory.build_python(
subject_id=CLASSROOMS_SUBJECT_IDS[
(i // len(CLASSROOMS_STATUSES))
% len(CLASSROOMS_SUBJECT_IDS)
],
),
status=CLASSROOMS_STATUSES[i % len(CLASSROOMS_STATUSES)],
tutor_id=student_user_id + i + 1,
created_at=last_created_at,
)
await Enrollment.create(
group_classroom_id=group_classroom.id,
student_id=student_user_id,
)
yield group_classroom
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: очень много одинакового в студенте и репетиторе, стоит чутка подобъединить, например, через общую функцию или фикстуру, которая чисто генерируется данные (kind, status, subject), но не создаёт ничего в БД

Comment on lines +209 to +220
filtered_tutor_classroom = [
classroom
for classroom in tutor_classrooms
if all(
(
statuses is None or classroom.status in statuses,
kinds is None or classroom.kind in kinds,
subject_ids is None or classroom.subject_id in subject_ids,
cursor is None or classroom.created_at < cursor.created_at,
)
)
]
Copy link
Member

@niqzart niqzart Jan 10, 2026

Choose a reason for hiding this comment

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

issue(repeat): некорректный нейминг переменной

Плюс некорректная типизация

CLASSROOMS_LIST_SIZE = 8
CLASSROOMS_STATUSES = list(ClassroomStatus)
CLASSROOMS_KINDS = list(ClassroomKind)
CLASSROOMS_SUBJECT_IDS = [*random.sample(range(1, 999), k=2), None]
Copy link
Member

Choose a reason for hiding this comment

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

issue: рандом в глобальном скоупе. Должен быть только в тестах и фикстурах

issue: нет типизации (важно из-за None)

Comment on lines +33 to +35
CLASSROOMS_LIST_SIZE = (
len(CLASSROOMS_SUBJECT_IDS) * len(CLASSROOMS_KINDS) * len(CLASSROOMS_STATUSES)
)
Copy link
Member

Choose a reason for hiding this comment

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

issue: некорректный размер датасета, нет константы

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +169 to +171
classroom_requests_filter = pytest.mark.parametrize(
("kinds", "statuses", "subject_ids"),
[
Copy link
Member

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

ci:covered If coverage checks should be run on the PR ci:migrated If migration checks should be run on the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants