Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_score(self, period):
- ''' Get the score for this goal '''
- # Agregar filtro para este goal
- executions = Execution.objects.filter(period=period)
- value = 0
- # Simple values
- value += executions.filter(
- indicator__in=self.indicator_set.filter(accumulated_value=False)
- ).aggregate(total=Coalesce(Sum('result'), 0))['total']
- # Accumulated values
- value += executions.filter(
- indicator__in=self.indicator_set.filter(
- accumulated_value=True,
- accumulated_graphic=True
- )
- ).aggregate(total=Coalesce(Sum('result_accumulated'), 0))['total']
- # Idicators that have been set as accumulated, but we need
- # retrieve the simple value.
- value += executions.filter(
- indicator__in=self.indicator_set.filter(
- accumulated_value=True,
- accumulated_graphic=False
- )
- ).aggregate(total=Coalesce(Sum('result'), 0))['total']
- return value
- def get_weight_value(self, goal, accumulated=False):
- ''' Get weight value, to be used in goals '''
- try:
- weight = GoalIndicator.objects.get(goal=goal, indicator=self.indicator)
- except:
- pass
- value = self.result_accumulated if accumulated else self.result
- return (value / weight) * 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement