Skip to content

Add func to migrate document_of auction#230

Open
andrey484 wants to merge 5 commits intoopenprocurement:masterfrom
andrey484:migration_func
Open

Add func to migrate document_of auction#230
andrey484 wants to merge 5 commits intoopenprocurement:masterfrom
andrey484:migration_func

Conversation

@andrey484
Copy link
Copy Markdown

@andrey484 andrey484 commented Feb 26, 2019

This change is Reviewable

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 26, 2019

Pull Request Test Coverage Report for Build 830

  • 2 of 12 (16.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 34.925%

Changes Missing Coverage Covered Lines Changed/Added Lines %
openprocurement/auctions/core/utils.py 2 12 16.67%
Totals Coverage Status
Change from base Build 824: -0.05%
Covered Lines: 1697
Relevant Lines: 4859

💛 - Coveralls

return period


def change_document_of(document):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Додай 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', [])])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Подвійний цикл з вкладеним 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', [])])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Тут також спростити.


status_list.append([change_document_of(auction_document) for auction_document in auction.get('documents', [])])

return any([any(status) for status in status_list])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Збільшити зрозумілість.
Вкладений any - погано.
Називати змінні за їхніми типами (status_list) - поганий тон. Як на рахунок statuses?
Але навіть statuses - незрозуміло, адже після проходження потрійного циклу (врахував listcomp) там лежать не просто statuses, а суперфільтровані_статуси_документів_не_знаю_навіщо_вони_тут. Треба писати так, щоб розумів не тільки автор.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Как насчет первой версии миграции
ab45895#diff-77d5d558041454211a2483e1df992200R590

@bdmbdsm bdmbdsm self-requested a review March 11, 2019 09:21
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.

4 participants