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

Ensures that active reviews count is accurate #4450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajrbyers
Copy link
Member

@ajrbyers ajrbyers commented Oct 8, 2024

Include both date_complete and is_complete in an OR filter when calculating a reviewers active review count.

Closes #4392

@@ -49,7 +50,8 @@ def get_reviewers(article, candidate_queryset, exclude_pks):
).exclude(date_complete__isnull=True).order_by("-date_complete")
)
active_reviews_count = models.ReviewAssignment.objects.filter(
is_complete=False,
Q(date_complete__isnull=True) | Q(is_complete=True),
Copy link
Member

@mauromsl mauromsl Dec 5, 2024

Choose a reason for hiding this comment

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

Did you mean to use an XOR operator?

Q objects and querysets can now be combined using ^ as the exclusive or (XOR) operator. XOR is natively supported on MariaDB and MySQL. For databases that do not support XOR, the query will be converted to an equivalent using AND, OR, and NOT.

https://docs.djangoproject.com/en/4.2/releases/4.1/#models

Also, it would be good to use a comment here explaining the implicitness of the query (we are trying to consider declined reviews) or maybe even use a variable/custom filter/custom manager method, e.g

INCOMPLETE_AND_NOT_DECLINED_FILTER = (Q(date_complete__isnull=True)^ Q(is_complete=True))

@mauromsl mauromsl assigned ajrbyers and unassigned mauromsl Dec 5, 2024
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.

Active reviews count is incorrect
2 participants