Commit 9859f3af authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

fix caching of `cytoxtest_av` and `tests_av` in Compound

fix #229
parent b95da243
Pipeline #33810 passed with stages
in 16 minutes and 2 seconds
......@@ -1495,21 +1495,14 @@ class ContributionManager(models.Manager):
if current_user.is_anonymous:
qs = qs.exclude(validated=False)
elif not current_user.is_superuser:
qs = qs.exclude(
Q(validated=False),
~Q(contributor=current_user),
)
qs = qs.exclude(Q(validated=False), ~Q(contributor=current_user),)
return qs
def validated(self):
"""
Get validated contributions
"""
return (
super()
.get_queryset()
.exclude(validated=False)
)
return super().get_queryset().exclude(validated=False)
class Contribution(models.Model):
......@@ -1814,13 +1807,9 @@ def update_compound_cached_properties(compounds_queryset=None):
)
.values("_bindtest_av")[:1]
),
pktest_av=Exists(
CompoundPKResult.objects.filter(id=OuterRef("id"))
),
cytoxtest_av=Subquery(
compounds_queryset.filter(id=OuterRef("id"))
.annotate(_cytoxtest_av=Count("compoundcytotoxicityresult", distinct=True))
.values("_cytoxtest_av")[:1]
pktest_av=Exists(CompoundPKResult.objects.filter(id=OuterRef("id"))),
cytoxtest_av=Exists(
CompoundCytotoxicityResult.objects.filter(id=OuterRef("id"))
),
insilico_av=Subquery(
compounds_queryset.filter(id=OuterRef("id"))
......@@ -1840,11 +1829,7 @@ def update_compound_cached_properties(compounds_queryset=None):
)
.values("_insilico_av")[:1]
),
tests_av=Subquery(
compounds_queryset.filter(id=OuterRef("id"))
.annotate(_tests_av=Count("compoundactivityresult", distinct=True))
.values("_tests_av")[:1]
),
tests_av=Exists(CompoundActivityResult.objects.filter(id=OuterRef("id"))),
)
compounds_queryset.update(
best_activity_ppi_family_name=Subquery(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment