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: pick the most recently start plan as auto-applicable #745

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

iloveagent57
Copy link
Contributor

@iloveagent57 iloveagent57 commented Dec 5, 2024

Description

Ensures that we pick the most recently started plan as the auto-applicable plan for an agreement.

Link to the associated ticket: https://openedx.atlassian.net/browse/ENT-9734

Testing considerations

  1. Create a customer agreement
  2. Create a current, active plan for the agreement and set should_auto_apply_licenses to true. Also set the start_date to 3 days ago. Save it. Call this plan 1.
  3. Note that the agreement record's "Subscription for auto applied licenses" is now plan 1.
  4. Create another current, active, auto-applicable plan for the agreement, set the start date to yesterday. Save it. call this plan 2.
  5. Refresh the agreement page, note that the Subscription for auto applied licenses value is now plan 2.

Post-review

Squash commits into discrete sets of changes

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -237,7 +237,7 @@ def auto_applicable_subscription(self):
is_active=True,
start_date__lte=now,
expiration_date__gte=now
).first()
).order_by('-start_date').first()
Copy link
Member

Choose a reason for hiding this comment

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

[sanity check] Just to confirm / for posterity, this change wouldn't incorrectly impact any other existing customers that might not have the same business rules as VSF, right (e.g., where they might want the plan with the earliest start_date), correct? Given that the query is technically non-deterministic today, where we previously assumed any active/current plan was suitable, making it deterministic now really isn't changing any prior expectations as a result. That said, there could be a future use case where the ordering might depend on customer-specific rules (though, probably a bridge to cross if/when that happens, not now).

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, exactly, although its probably deterministic today based on the row id in the database.

@iloveagent57 iloveagent57 force-pushed the aed/auto-apply-sorting branch from c2863a8 to 4f7e6da Compare December 5, 2024 20:50
" will automatically enable the \"Should auto apply licenses\" field on the subscription plan"
help_text=(
"""
The subscription plan from which licenses will be auto-applied, if any.
Copy link
Member

Choose a reason for hiding this comment

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

Nice update/clarification on the help_text.

@iloveagent57 iloveagent57 merged commit a9255d3 into master Dec 5, 2024
5 checks passed
@iloveagent57 iloveagent57 deleted the aed/auto-apply-sorting branch December 5, 2024 21:04
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