Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Валидация данных в юзердате #19

Closed
viribus-issue-bot opened this issue Aug 31, 2023 · 3 comments · Fixed by #42
Closed

Валидация данных в юзердате #19

viribus-issue-bot opened this issue Aug 31, 2023 · 3 comments · Fixed by #42
Assignees
Labels
good first issue 👶 Задача подходит для новичков

Comments

@viribus-issue-bot
Copy link

Issue open by Артем Морозов via telegram message.

@github-project-automation github-project-automation bot moved this to Backlog in Viribus Team Aug 31, 2023
@Temmmmmo Temmmmmo moved this from Backlog to Todo in Viribus Team Aug 31, 2023
@grigoriev-semyon grigoriev-semyon changed the title Придумать способ валидации данных в юзердате Валидация данных в юзердате Sep 4, 2023
@grigoriev-semyon
Copy link
Member

grigoriev-semyon commented Sep 4, 2023

  1. Добавить в БД в таблицу Param колонку validation - тип - строка нуллабл
  2. При обновлении регулярки чекать, что она компилируется
  3. При обновлении данных чекать совпадение
  4. Регулярку отдавать вместе с параметрами в соотв вызовах(параметров и категорий)
  5. GET /userdata не валидировать

@grigoriev-semyon grigoriev-semyon removed their assignment Sep 4, 2023
@grigoriev-semyon grigoriev-semyon added the good first issue 👶 Задача подходит для новичков label Sep 4, 2023
@Arzangulyan Arzangulyan moved this from Todo to Backlog in Viribus Team Mar 11, 2024
@Arzangulyan Arzangulyan moved this from Backlog to Todo in Viribus Team Jul 8, 2024
@grigoriev-semyon
Copy link
Member

Еще необходимо написать скрипт SQL, который выдает непрошедшие вариацию записи в БД
Чтобы сделать ручную миграцию в момент раскатки

@Temmmmmo Temmmmmo moved this from Todo to In Progress in Viribus Team Jul 22, 2024
@DaymasS DaymasS linked a pull request Jul 25, 2024 that will close this issue
3 tasks
@DaymasS
Copy link
Contributor

DaymasS commented Jul 25, 2024

Скрипт для ручной миграции

from re import search

from sqlalchemy import create_engine, not_
from sqlalchemy.orm import sessionmaker

from settings import get_settings
from userdata_api.exceptions import ObjectNotFound
from userdata_api.models.db import Info, Param


def create_session():
    settings = get_settings()
    engine = create_engine(str(settings.DB_DSN))
    TestingSessionLocal = sessionmaker(bind=engine)
    return TestingSessionLocal()


def validate_info():
    dbsession = create_session()
    info_list = (
        dbsession.query(Info)
        .join(Param)
        .filter(Param.validation != None, not_(Info.is_deleted))
        .order_by(Info.owner_id)
        .all()
    )
    print("Invalid userdata:\n")
    for info in info_list:
        param = dbsession.query(Param).filter(Param.id == info.param_id).one_or_none()
        if not param:
            raise ObjectNotFound(Param, info.param_id)
        if not search(param.validation, info.value):
            print(info, end="\n\n")

@github-project-automation github-project-automation bot moved this from In Progress to Done in Viribus Team Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue 👶 Задача подходит для новичков
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants