profcomff / profcomff/modal-service-api

Ручка получения модалок

Open
#39 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
0
Avg merge
18d 7h
Merged PRs (30d)
2

Description

GET /user/notifications

Возвращает очередь модалок для показа текущему пользователю в конкретном сервисе.

Параметры: service_id (обязательный, из токена бэк знает юзера, но не знает, где он сейчас) и limit (по умолчанию 5, максимум 20).

Что делает: увеличивает счётчик заходов юзера в этот сервис в таблице user_visit, берёт группы юзера из данных UnionAuth, отбирает подходящие модалки, сортирует по priority по убыванию и created_at по возрастанию, режет по limit. Показы при этом не засчитывает, для этого есть отдельная ручка POST /user/{id}/view.

Модалка попадает в очередь, если выполнены все условия сразу: статус ACTIVE и не удалена, start_ts пустой или уже наступил, is_always или end_ts ещё не прошёл, service_id есть в её service_ids, группы юзера пересекаются с её group_ids, юзер на неё ещё не отвечал (нет записи в note_response), отклонял меньше двух раз, показов меньше max_shows если он задан, и либо показов ещё не было, либо с последнего показа прошло не меньше frequency заходов (visit_no минус last_visit_no).

Ответ — список полных объектов модалок с полями своего типа. Админские поля не отдаём: admin_id, status, view_count, rejected_count, is_deleted, group_ids, service_ids, frequency, priority, max_shows. Если ничего не подошло — 200 и пустой список, не 404. Несуществующий service_id тоже не ошибка, просто пустой список.

Ошибки: 401 без авторизации, 422 если не передан service_id.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GET /user/notifications entry point and trace how authentication, UnionAuth groups, user_visit, and note_response are represented. Verify the filtering, ordering, limit validation, response field exclusions, and empty-result behavior against the described rules; done means authorized requests return the correct modal queue while missing service_id returns 422.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.