-
Notifications
You must be signed in to change notification settings - Fork 2
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
Create Entities #57
Conversation
53dfb78
to
6935d84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@astronik00 Закончила ревью по текущему коду. Считаю, что нужно провести следующие тесты для проверки связей и поиска возможных ошибок:
- Удаление сервера - должны быть удалены все задачи и категории
- Удаление задачи - удаление связанного label
- Если возможно удалять или изменять категории из доступных - удаление или изменения соотвествующего атрибута в label
Code/entities/local/task.py
Outdated
|
||
# keys | ||
task_id = Column(Integer, primary_key=True, autoincrement=True) | ||
server_id = Column(Integer, ForeignKey('server.server_id')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно поставить ondelete=cascade тоже, при удалении сервера должны удаляться все задачи, связанные с этим сервером
Code/entities/local/task.py
Outdated
self.due = due | ||
self.last_mod = last_mod | ||
self.status = status | ||
self.labels = labels |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это призрак прошлой версии, не заметила лишнего поля. Его быть не должно
type_id = Column(Integer, ForeignKey('type.type_id')) | ||
status_id = Column(Integer, ForeignKey('status.status_id')) | ||
|
||
task = relationship("Task", back_populates="label") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Такой же вопрос - в конструкторе Task указан labels, тут label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не прописан cascade на случай удаления задачи
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labels - лишнее поле, которое я уберу
должен быть лишь label, который является отношением для создания связи один ко одному
ок, cascade посмотрю и добавлю
Code/entities/local/label.py
Outdated
priority = relationship("Priority", back_populates="labels") | ||
size = relationship("Size", back_populates="labels") | ||
type = relationship("Type", back_populates="labels") | ||
status = relationship("Status", back_populates="labels") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В текущей версии предусмотрен случай удаления или изменения какой-то категории из доступного набора?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь не нужен автоинкремент? В конструкторе id тоже не назначается
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Такой же вопрос к сущностям Size, Status, Type
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужен cascade при удалении сервера
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Такой же вопрос к сущностям Size, Status, Type
Code/entities/local/label.py
Outdated
|
||
def __init__(self, task, priority=None, size=None, type=None, status=None): | ||
self.task = task | ||
self.prioriry = priority |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Опечатка: должно быть "priority"
Code/entities/local/task.py
Outdated
due = Column(DateTime) | ||
last_mod = Column(DateTime) | ||
|
||
status = Column(Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Атрибут status лишний, он уже есть в сущности Label
Не думаю, что эти тесты входят именно в эту задачу. У меня есть задача "написать репозиторий задач", я считаю, что это должно фигурировать там. Ну и если у меня что-то не будет работать в репозитории, то я просто сюда вернусь и исправлю. А так все тесты объективны и понятны, только тесты сервера - это в принципе даже к моей задаче не относится... Я пишу функции работы с задачами, а то что-то слишком мне много делать :/ |
d72c146
to
4f4d055
Compare
Я внесла все исправления |
4f4d055
to
3a67d71
Compare
@astronik00 Хорошо, просто при чтении кода возникли такие мысли для тестов. Может быть тесты вынести в отдельную задачу? Почему удаление сервера не относится? Имеется ввиду удаление сущности Server. Я могу помочь с этой задачей, после того, как доделаю валидацию. |
@astronik00 Сейчас посмотрю |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@astronik00 Других замечаний нет. В целом все хорошо
Code/entities/local/labels/status.py
Outdated
__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')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я верно понимаю, что добавление каскадного удаления не относится к задаче по созданию сущностей? Или почему тут закомментирован альтернативный внешний ключ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я верно понимаю, что добавление каскадного удаления не относится к задаче по созданию сущностей? Или почему тут закомментирован альтернативный внешний ключ?
Я не понимаю, КАК эта версия попала на гитхаб, если я залила следующую версию кода и на локалке она у меня отображается запушенной (т.е с каскадным удалением):
У меня кстати аналогичная проблема - на локальной версии файл "Server.py" написан "server.py", но заливая каждый раз сюда, он становится с большой буквы. Я не понимаю, как это происходит
67d571a
to
74a5845
Compare
Added Labels: Size, Status, Type, Priority, Label Base Entities: Server, Task
74a5845
to
a885312
Compare
Task merge request
умение проектировать схемы баз данных
Code changes
Созданы следующие модули python:
Созданы следующие новые классы:
Task
- класс задачи VTODOServer
- класс сервера, который содержит в себе данные для подключенияLabel
- промежуточный класс, который агрегирует в себе лейблыSize
- класс лейблов для размера задачиStatus
- класс лейблов для статуса задачиType
- класс лейблов для типа задачиPriotiry
- класс лейблов для приоритета задачиHow to test