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: new mgmt command to validate default enrollment intentions #2321

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

pwnage101
Copy link
Contributor

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

Comment on lines +34 to +35
default=30,
help="How long after a customer's catalog has been updated are we allowed to evaluate the customer."
Copy link
Contributor Author

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.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-9941 branch 4 times, most recently from 1255aca to 6f5ff84 Compare January 28, 2025 00:00
@pwnage101 pwnage101 marked this pull request as ready for review January 28, 2025 00:01
Copy link
Contributor

@iloveagent57 iloveagent57 left a 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.

Comment on lines +2729 to +2736
def __str__(self):
"""
Return human-readable string representation.
"""
return (
f"<DefaultEnterpriseEnrollmentIntention for customer={self.enterprise_customer.uuid} "
f"and content_key={self.content_key}>"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines 96 to 93
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",
)
Copy link
Contributor

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?

Copy link
Contributor

@iloveagent57 iloveagent57 left a 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!

Comment on lines 96 to 99
customers_with_intentions = DefaultEnterpriseEnrollmentIntention.objects.values_list(
"enterprise_customer__uuid",
)
customers_with_intentions = [values[0] for values in customers_with_intentions]
Copy link
Contributor

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.

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
@pwnage101 pwnage101 merged commit 7860752 into master Jan 29, 2025
10 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-9941 branch January 29, 2025 18:01
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