-
Notifications
You must be signed in to change notification settings - Fork 1
352 DB limitation #427
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
352 DB limitation #427
Conversation
app/mongo_odm.py
Outdated
| meta.save() | ||
|
|
||
| def check_storage_limit(self, new_file_size): | ||
| max_size = int(Config.c.constants.storage_max_size_mbytes)*1024*1024 |
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.
Поскольку вы вынесли логику в DBManager - давайте лимит запишем в его поле (тогда не нужно будет каждый раз преобразовывать данные из конфига)
app/mongo_odm.py
Outdated
| except: | ||
| if(isinstance(file, str)): | ||
| size = len(file) | ||
| self.check_storage_limit(size) |
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.
кажется, в тестовом конфиге это тоже пригодится - как минимум, для selenium-теста, проверяющего страницу capacity
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.
Добавьте ссылку на эту страницу в /admin
app/mongo_odm.py
Outdated
|
|
||
| class DBManager: | ||
| def __new__(cls): | ||
| def __new__(cls, max_size=20000): # max_size only on first creation, in MB |
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.
Максимальный размер для БД укажите в конфиге - раздел [constants] для этого подойдет
app/api/files.py
Outdated
| if not DBManager().check_storage_limit(request.content_length * 2.5): | ||
| return { | ||
| 'message': "Not enough place in database to store file" | ||
| }, 404 |
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.
Измените код на 413 (он тут более логичен - в 146 строчке тоже обновите) и добавьте обработку этой ошибки на клиенте - чтобы пользователь не гадал что и как сломалось (для случая переполнения БД добавьте сообщение, что необходимо обратиться по почте - она есть в конфиге в разделе bugreport)
| meta = StorageMeta(used_size=0).save() | ||
| return meta | ||
|
|
||
| def get_used_storage_size(self): |
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.
добавьте метод для актуализации данных (вдруг где-то логика дала сбой и насчитала нам что-то, или вручную из бд были удалены файлы) - ему нужно будет пройтись по всем документам и посчитать их общий вес
- на странице capacity сделайте кнопку для такого обновления данных, чтобы по запросу пересчитывать размер и выводить актуальный
No description provided.