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

Create Entities #57

Merged
merged 1 commit into from
Apr 30, 2023
Merged

Conversation

astronik00
Copy link
Collaborator

@astronik00 astronik00 commented Apr 28, 2023

Task merge request


Related Issue #45
Reviewer requrements Знание принципов работы ORM фреймворков,

умение проектировать схемы баз данных

Code changes

Созданы следующие модули python:

  1. task.py
  2. server.py
  3. label.py
  4. size.py
  5. status.py
  6. type.py
  7. priority.py

Созданы следующие новые классы:

  1. Task - класс задачи VTODO
  2. Server - класс сервера, который содержит в себе данные для подключения
  3. Label - промежуточный класс, который агрегирует в себе лейблы
  4. Size - класс лейблов для размера задачи
  5. Status - класс лейблов для статуса задачи
  6. Type - класс лейблов для типа задачи
  7. Priotiry - класс лейблов для приоритета задачи

How to test

  1. Просмотреть схему баз данных:
    image
  2. Ознакомиться с документацией по работе с relationship в SQLAlchemy, а также эту документацию по работе с Adjacency List
  3. Соотнести соответствие схемы и всех полей классов, проверить правильность расставленных отношений, в том числе и ключей

@astronik00 astronik00 added the documentation Improvements or additions to documentation label Apr 28, 2023
@astronik00 astronik00 self-assigned this Apr 28, 2023
@astronik00 astronik00 removed the documentation Improvements or additions to documentation label Apr 28, 2023
@astronik00 astronik00 changed the title Created Entities Create Entities Apr 28, 2023
Copy link
Contributor

@aleksandra-shchegoleva aleksandra-shchegoleva left a comment

Choose a reason for hiding this comment

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

@astronik00 Закончила ревью по текущему коду. Считаю, что нужно провести следующие тесты для проверки связей и поиска возможных ошибок:

  1. Удаление сервера - должны быть удалены все задачи и категории
  2. Удаление задачи - удаление связанного label
  3. Если возможно удалять или изменять категории из доступных - удаление или изменения соотвествующего атрибута в label


# keys
task_id = Column(Integer, primary_key=True, autoincrement=True)
server_id = Column(Integer, ForeignKey('server.server_id'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Нужно поставить ondelete=cascade тоже, при удалении сервера должны удаляться все задачи, связанные с этим сервером

self.due = due
self.last_mod = last_mod
self.status = status
self.labels = labels
Copy link
Contributor

Choose a reason for hiding this comment

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

Поле labels - как я вижу это не атрибут таблицы task. Судя по конструктору оно хранит список (список сущностей Label?). Для чего нужно это поле? Возможно имелось ввиду label? Почему на вход подается список, а не сущность Label?

Copy link
Collaborator Author

@astronik00 astronik00 Apr 28, 2023

Choose a reason for hiding this comment

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

Это призрак прошлой версии, не заметила лишнего поля. Его быть не должно

Code/entities/local/Server.py Outdated Show resolved Hide resolved
type_id = Column(Integer, ForeignKey('type.type_id'))
status_id = Column(Integer, ForeignKey('status.status_id'))

task = relationship("Task", back_populates="label")
Copy link
Contributor

Choose a reason for hiding this comment

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

Такой же вопрос - в конструкторе Task указан labels, тут label

Copy link
Contributor

Choose a reason for hiding this comment

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

Не прописан cascade на случай удаления задачи

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

labels - лишнее поле, которое я уберу
должен быть лишь label, который является отношением для создания связи один ко одному

ок, cascade посмотрю и добавлю

Comment on lines 17 to 20
priority = relationship("Priority", back_populates="labels")
size = relationship("Size", back_populates="labels")
type = relationship("Type", back_populates="labels")
status = relationship("Status", back_populates="labels")
Copy link
Contributor

Choose a reason for hiding this comment

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

В текущей версии предусмотрен случай удаления или изменения какой-то категории из доступного набора?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

нет, но это не отменяет, что эти отношения нужны для поддержания связи, ибо если время будет, то такой сервис для изменения будет добавлен


__tablename__ = 'priority'

priority_id = Column(Integer, primary_key=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Здесь не нужен автоинкремент? В конструкторе id тоже не назначается

Copy link
Contributor

Choose a reason for hiding this comment

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

Такой же вопрос к сущностям Size, Status, Type

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

автоинкремент добавлю

name = Column(String)

# M:1
server = relationship("Server", back_populates="priorities")
Copy link
Contributor

Choose a reason for hiding this comment

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

Нужен cascade при удалении сервера

Copy link
Contributor

Choose a reason for hiding this comment

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

Такой же вопрос к сущностям Size, Status, Type


def __init__(self, task, priority=None, size=None, type=None, status=None):
self.task = task
self.prioriry = priority
Copy link
Contributor

Choose a reason for hiding this comment

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

Опечатка: должно быть "priority"

due = Column(DateTime)
last_mod = Column(DateTime)

status = Column(Integer)
Copy link
Contributor

Choose a reason for hiding this comment

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

Атрибут status лишний, он уже есть в сущности Label

@astronik00
Copy link
Collaborator Author

astronik00 commented Apr 28, 2023

@astronik00 Закончила ревью по текущему коду. Считаю, что нужно провести следующие тесты для проверки связей и поиска возможных ошибок:

  1. Удаление сервера - должны быть удалены все задачи и категории
  2. Удаление задачи - удаление связанного label
  3. Если возможно удалять или изменять категории из доступных - удаление или изменения соотвествующего атрибута в label

Не думаю, что эти тесты входят именно в эту задачу.

У меня есть задача "написать репозиторий задач", я считаю, что это должно фигурировать там. Ну и если у меня что-то не будет работать в репозитории, то я просто сюда вернусь и исправлю.

А так все тесты объективны и понятны, только тесты сервера - это в принципе даже к моей задаче не относится... Я пишу функции работы с задачами, а то что-то слишком мне много делать :/

@astronik00 astronik00 force-pushed the 45-create-entity-classes branch 3 times, most recently from d72c146 to 4f4d055 Compare April 28, 2023 14:32
@astronik00
Copy link
Collaborator Author

@aleksandra-shchegoleva

Я внесла все исправления

@aleksandra-shchegoleva
Copy link
Contributor

@astronik00 Хорошо, просто при чтении кода возникли такие мысли для тестов. Может быть тесты вынести в отдельную задачу? Почему удаление сервера не относится? Имеется ввиду удаление сущности Server. Я могу помочь с этой задачей, после того, как доделаю валидацию.

@aleksandra-shchegoleva
Copy link
Contributor

@aleksandra-shchegoleva

Я внесла все исправления

@astronik00 Сейчас посмотрю

Copy link
Contributor

@aleksandra-shchegoleva aleksandra-shchegoleva left a comment

Choose a reason for hiding this comment

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

@astronik00 Других замечаний нет. В целом все хорошо

__tablename__ = 'status'

status_id = Column(Integer, primary_key=True, autoincrement=True)
server_id = Column(Integer, ForeignKey('server.server_id')) # ForeignKey('server.server_id'), ondelete='CASCADE'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Я верно понимаю, что добавление каскадного удаления не относится к задаче по созданию сущностей? Или почему тут закомментирован альтернативный внешний ключ?

Copy link
Collaborator Author

@astronik00 astronik00 Apr 29, 2023

Choose a reason for hiding this comment

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

Я верно понимаю, что добавление каскадного удаления не относится к задаче по созданию сущностей? Или почему тут закомментирован альтернативный внешний ключ?

Я не понимаю, КАК эта версия попала на гитхаб, если я залила следующую версию кода и на локалке она у меня отображается запушенной (т.е с каскадным удалением):
image

У меня кстати аналогичная проблема - на локальной версии файл "Server.py" написан "server.py", но заливая каждый раз сюда, он становится с большой буквы. Я не понимаю, как это происходит

Added Labels: Size, Status, Type, Priority, Label
Base Entities: Server, Task
@astronik00 astronik00 merged commit f95d1dd into 46-create-local-taskservice Apr 30, 2023
@astronik00 astronik00 deleted the 45-create-entity-classes branch May 24, 2023 20:17
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