From 792a1293d65ae52e858b5dfeed1a29c9adedfe7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20M=C3=A9nager?= <herve.menager@pasteur.fr> Date: Thu, 25 Jun 2020 09:37:01 +0200 Subject: [PATCH] correct the computing of pktest_av and cytoxtest_av for Compound fix #223 --- ippisite/ippidb/models.py | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 651ccd97..a82a1915 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -1747,37 +1747,12 @@ def update_compound_cached_properties(compounds_queryset=None): ), pktest_av=Subquery( compounds_queryset.filter(id=OuterRef("id")) - .annotate( - _pktest_av=Cast( - Max( - Case( - When( - refcompoundbiblio__bibliography__pharmacokinetic=True, - then=1, - ), - default=0, - output_field=IntegerField(), - ) - ), - BooleanField(), - ) - ) + .annotate(_pktest_av=Count("compoundpkresult", distinct=True)) .values("_pktest_av")[:1] ), cytoxtest_av=Subquery( compounds_queryset.filter(id=OuterRef("id")) - .annotate( - _cytoxtest_av=Cast( - Max( - Case( - When(refcompoundbiblio__bibliography__cytotox=True, then=1), - default=0, - output_field=IntegerField(), - ) - ), - BooleanField(), - ) - ) + .annotate(_cytoxtest_av=Count("compoundcytotoxicityresult", distinct=True)) .values("_cytoxtest_av")[:1] ), insilico_av=Subquery( -- GitLab