-
Notifications
You must be signed in to change notification settings - Fork 48
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: new mgmt command to validate default enrollment intentions #2321
Conversation
default=30, | ||
help="How long after a customer's catalog has been updated are we allowed to evaluate the customer." |
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.
30 minutes is a wild guess, I'll probably take a look at some real life task durations and come up with something more accurate.
1255aca
to
6f5ff84
Compare
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.
Looks great, only suggestion is to do it without fetching all EnterpriseCustomers.
def __str__(self): | ||
""" | ||
Return human-readable string representation. | ||
""" | ||
return ( | ||
f"<DefaultEnterpriseEnrollmentIntention for customer={self.enterprise_customer.uuid} " | ||
f"and content_key={self.content_key}>" | ||
) |
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.
✨
customers = EnterpriseCustomer.objects.annotate( | ||
catalogs_modified_latest=Greatest( | ||
Max("enterprise_customer_catalogs__modified"), | ||
Max("enterprise_customer_catalogs__enterprise_catalog_query__modified"), | ||
), | ||
).prefetch_related( | ||
"default_enrollment_intentions", | ||
) |
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.
Will this fetch all enterprise customer records? Can we do it in "reverse" by first identifying only the customers that have any default enrollment intentions?
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.
Looks great, don't forget version bump!
customers_with_intentions = DefaultEnterpriseEnrollmentIntention.objects.values_list( | ||
"enterprise_customer__uuid", | ||
) | ||
customers_with_intentions = [values[0] for values in customers_with_intentions] |
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.
FYI you can pass in flat=True
to values list if you're only selecting a single column, and that will give you back singles values instead of 1-tuples.
af3a218
to
8a36ff6
Compare
Introduced validate_default_enrollment_intentions.py to check that all DefaultEnterpriseEnrollmentIntention objects have a valid content_key which actually belongs to at least one of the related customer's catalogs. ENT-9941
8a36ff6
to
553eef6
Compare
Introduced validate_default_enrollment_intentions.py to check that all DefaultEnterpriseEnrollmentIntention objects have a valid content_key which actually belongs to at least one of the related customer's catalogs.
ENT-9941