Skip to content
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

feat: add allocate_assignments method to content_assignments app. #271

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

iloveagent57
Copy link
Contributor

ENT-7531

@iloveagent57 iloveagent57 force-pushed the aed/allocate-from-policy branch 2 times, most recently from 03aba6b to 9c813a1 Compare September 20, 2023 14:07
For existing assignment records with a (config, learner, content) combination, this function
does the following:
* If the existing record is cancelled or errored, update the existing record state to allocated
* If the existing record is allocated or accepted, don't do anything with the record
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking product question to ponder: if an existing record is allocated, should a notification be re-sent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the state changes from cancelled or errored, then yes.

Comment on lines +165 to +168
def _create_new_assignments(assignment_configuration, learner_emails, content_key, content_price_cents):
"""
Helper to bulk save new LearnerContentAssignment instances.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future, is this the function that also kicks off linking/notification tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, either here, or do it directly from allocated_assignments() above, calling something like notify_learner() on the updated_assignments and created_assignments records.

)

@classmethod
def bulk_create(cls, assignment_records):
Copy link
Contributor

@pwnage101 pwnage101 Sep 21, 2023

Choose a reason for hiding this comment

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

Nit: The naming of this method feels potentially confusing. Callers call model.bulk_create() which calls bulk_create_with_history() which calls model.manager.bulk_create(). The first and last sharing the same name is what's weird for me, since the latter is already well documented. Can you just call this method bulk_create_with_history()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point, I'll change that name in an upcoming PR.

Copy link
Contributor

@pwnage101 pwnage101 left a comment

Choose a reason for hiding this comment

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

the rest LGTM!

@iloveagent57 iloveagent57 merged commit 6ca4793 into main Sep 25, 2023
2 checks passed
@iloveagent57 iloveagent57 deleted the aed/allocate-from-policy branch September 25, 2023 13:32
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.

2 participants