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
hw6 web fixed Denis Tsapaev #535
base: homework_06_web
Are you sure you want to change the base?
Conversation
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.
Не большое преревью :)
|
||
|
||
def select_all(sort_by, filter_field, filter_value): | ||
with open("data.json", 'r', encoding='utf-8')as file: |
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.
Перекрываешь встроенный метод file
и странно, что в пепе нет пробела перед as
, так себе выглядит :)
with open("data.json", 'r', encoding='utf-8')as file: | ||
data = json.loads(file.read()) | ||
try: | ||
del data[str(id_flight)] | ||
with open("data.json", 'w', encoding='utf-8')as file: | ||
json.dump(data, file, ensure_ascii=False, indent=4) |
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.
Почитай https://ru.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself и подумай, как бы круто код выглядел, вынеси ты общение с бд (файлом) в отдельный класс.
2019-11-02 19:40:15,797 - flask.app - INFO - {'url': 'http://localhost:5000/update_flight', 'args': {}, 'body': {'id_flight': '3', 'flight': {'departure_time': 1600, 'arrival_time': '17:00', 'travel_time': '01:00', 'destination_airport': 'Vnukovo', 'type_aircraft': 'TU'}}, 'req_method': 'PUT', 'duration': 0.003, 'response': <Response 77 bytes [400 BAD REQUEST]>, 'http_status': 400} | ||
2019-11-02 19:40:15,797 - werkzeug - INFO - 127.0.0.1 - - [02/Nov/2019 19:40:15] "PUT /update_flight HTTP/1.1" 400 - |
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.
Все еще скудное журналирование. Как я по этому логу пойму из-за чего, четырехсотка? Этот лог увидит только админ, админ должен понимать что творит сервис без чтения кода. Нормальная тема, когда сервис гигабайты логов в день генерируют, именно для этого есть такое, как "ротация логов". Да, и фича с уровнем логгирования. Когда без изменения кода можно включить дополнительный уровень логов. Пока не зачет :)
Добавлены сортировка, фильтры и логирование