diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 651ccd979e8e4ced4ca18d93cf562a7da84cf535..a82a1915b20a70da7f0e2e1bb0687d18c24e6eaf 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(