Add func to migrate document_of auction#230
Add func to migrate document_of auction#230andrey484 wants to merge 5 commits intoopenprocurement:masterfrom
Conversation
Pull Request Test Coverage Report for Build 830
💛 - Coveralls |
| return period | ||
|
|
||
|
|
||
| def change_document_of(document): |
There was a problem hiding this comment.
Додай docstring, яка пояснює для чого служить ця функція, будь ласка. І не забудь вказати, що вона тільки для міграцій.
|
|
||
| for _type in ['bids', 'awards', 'contracts', 'cancellations']: | ||
| for type_array in auction.get(_type, []): | ||
| status_list.append([change_document_of(document) for document in type_array.get('documents', [])]) |
There was a problem hiding this comment.
Подвійний цикл з вкладеним list comprehension не викликає сумнівів в знанні циклів та list comprehensions, але це треба спростити. І прокоментувати спрощене.
| for type_array in auction.get(_type, []): | ||
| status_list.append([change_document_of(document) for document in type_array.get('documents', [])]) | ||
|
|
||
| status_list.append([change_document_of(auction_document) for auction_document in auction.get('documents', [])]) |
|
|
||
| status_list.append([change_document_of(auction_document) for auction_document in auction.get('documents', [])]) | ||
|
|
||
| return any([any(status) for status in status_list]) |
There was a problem hiding this comment.
Збільшити зрозумілість.
Вкладений any - погано.
Називати змінні за їхніми типами (status_list) - поганий тон. Як на рахунок statuses?
Але навіть statuses - незрозуміло, адже після проходження потрійного циклу (врахував listcomp) там лежать не просто statuses, а суперфільтровані_статуси_документів_не_знаю_навіщо_вони_тут. Треба писати так, щоб розумів не тільки автор.
There was a problem hiding this comment.
Как насчет первой версии миграции
ab45895#diff-77d5d558041454211a2483e1df992200R590
This change is