Skip to content

WIP: фильтрация отзывов у преподавателя#100

Open
didu4 wants to merge 2 commits intomainfrom
rating-ui-lecture-subject
Open

WIP: фильтрация отзывов у преподавателя#100
didu4 wants to merge 2 commits intomainfrom
rating-ui-lecture-subject

Conversation

@didu4
Copy link
Copy Markdown
Contributor

@didu4 didu4 commented Mar 22, 2026

Изменения

Реализую фильтрацию отзывов по предмету у преподавателей (В процессе)

Детали реализации

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

const middleName = ref(lecturer?.middle_name);
const avatarLink = ref(lecturer?.avatar_link);
const lecturerSubjects = ref(lecturer?.subjects);
const lecturer = ref<any>(null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Есть специальный тип Lecturer

const howKind = lecturer?.mark_kindness_weighted ?? 0;
const howFree = lecturer?.mark_freebie_weighted ?? 0;
const howClear = lecturer?.mark_clarity_weighted ?? 0;
async function init() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

А зачем так? Как будто достаточно присваивание засунуть в LoadLecturer и вызвать с subject=null

/>

<div class="mb-3">
<v-chip class="mr-2 mb-2" :color="selectedSubject === null ? 'primary' : ''" @click="filterBySubject(null)">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

В целом норм, но глянь еще v-chip-group


await store.init(lecturerId);

const lecturer = computed(() => store.lecturer);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Тебе computed здесь не нужен больше. Теперь можно либо:

  1. Обращаться через store.lecturer
  2. Деструктурировать весь стор const {lecturer} = toRefs(store)

const lecturer = computed(() => store.lecturer);
const selectedSubject = computed(() => store.selectedSubject);
const lecturerPhoto = computed(() => store.lecturerPhoto);
const firstName = computed(() => lecturer.value?.first_name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Вот здесь уже computed нужен, но лучше вынести их в стор. Посмотри про геттеры: https://pinia.vuejs.org/core-concepts/getters.html#Usage-with-setup-

const howKind = lecturer?.mark_kindness_weighted ?? 0;
const howFree = lecturer?.mark_freebie_weighted ?? 0;
const howClear = lecturer?.mark_clarity_weighted ?? 0;
const howKind = computed(() => lecturer.value?.mark_kindness_weighted ?? 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Аналогично, давай уберем в стор

const howClear = computed(() => lecturer.value?.mark_clarity_weighted ?? 0);

const lecturerPhoto = getPhoto(avatarLink.value);
function filteredBySubject(subject: string | null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Корректнее использовать глагол (чутка душно, но правда)

Лучше filterBySubject, а эту функцию назвать типа handleFilter

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants