diff --git a/beat/web/algorithms/models.py b/beat/web/algorithms/models.py index c45c2adffe65df4391d823f13d37179aac06593e..de61820997664c675f320289240d006a42a1b664 100755 --- a/beat/web/algorithms/models.py +++ b/beat/web/algorithms/models.py @@ -204,7 +204,7 @@ class Algorithm(Code): Returns: list: mapping environment to usage counts, determining how many times - a given algorithm has been successfuly used on that environment + a given algorithm has been successfully used on that environment """ @@ -213,27 +213,25 @@ class Algorithm(Code): from ..backend.models import Environment # Tries to figure through a maximum if an algorithm has been - # successfuly used inside an environment. + # successfully used inside an environment. # Case 1) The block is part of an experiment that was successful # Case 2) The block is part of an experiment that is not successful # (failed or other), but it is CACHED (if not cached, then we can't # attest anything about the algorithm/environment relationship!) - envs = ( + return ( Environment.objects.filter( blocks__in=self.blocks.filter( Q(experiment__status=Experiment.DONE) | ((~Q(experiment__status=Experiment.DONE)) & Q(status=Block.DONE)) ) ) - .annotate(itemcount=Count("id")) + .annotate(use_count=Count("id")) .order_by("-creation_date") .distinct() ) - return [(k, k.itemcount) for k in envs] - # _____ Overrides __________ def save(self, *args, **kwargs):