-
Notifications
You must be signed in to change notification settings - Fork 27
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
Commencements made #1990
Commencements made #1990
Conversation
very nice! |
commenced_counts = Commencement.objects.filter(commencing_work=work).values("commenced_work").annotate(num_commencements=Count("id")).order_by() | ||
multiple_commencements = commenced_counts.filter(num_commencements__gt=1).values_list("commenced_work", flat=True) | ||
single_commencements = commenced_counts.filter(num_commencements=1).values_list("commenced_work", flat=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.
so here we should also be taking into account any other existing commencements on all the commenced works, as you rightly pointed out in your video.
- if any of those other commencements is already
main
, don't set any of ours tomain
. if none are, we can still use the earliest (or only) one that we're adding - if any have
all_provisions=True
, we should set that to False and save that commencement, and make ours False as well
you can probably treat all 'multiple' and 'single' commencements the same, as long as
- the single and multiple lists are based on all commencements on the commenced work (Commencement.filter(commenced_work=commenced_work))
- the multiples logic is tweaked to check for existing
main
andall_provisions
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.
@goose-life I've updated the PR with our changes and its working ok. See the demo https://www.loom.com/share/0a35e3c039d948deb5eb802708e8c4fd?sid=73bc0379-b580-4c2e-b4c3-2843677f8f71
I think some of your logic around 'if commencement made / else commenced by' can probably come out, as we likely won't be reusing too much of the commencements for the other side of the relationship — but it doesn't hurt to leave it in for now and see, maybe we do end up reusing some of it! |
@goose-life I've removed references to the commenced_by in the code. I don't think we will use it if we do commenced_by separately. |
https://www.loom.com/share/aeb2c485ea164afcbef8b253776d3d27?sid=9618bf0d-59ee-43e0-b47e-124b764e9ee3