diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-14 18:40:51 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-14 18:40:51 +0100 |
commit | f149232155219bdb5f9e73c580bb0e0b3d285ae8 (patch) | |
tree | c0b84fdb9e0ce87552db8b7c605d5b8c35b47cf9 | |
parent | 037f06b038ac3deb8c5d87c94455241cfa58f05c (diff) | |
download | Ishtar-f149232155219bdb5f9e73c580bb0e0b3d285ae8.tar.bz2 Ishtar-f149232155219bdb5f9e73c580bb0e0b3d285ae8.zip |
Dashboard: fix area unity and effective operation tables (refs #3217)
-rw-r--r-- | archaeological_operations/models.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index bb1f2a256..3b06bc449 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1666,7 +1666,7 @@ class OperationDashboard: .annotate(number=Sum('surface')).all() val = 0 if area_res: - val = area_res[0].number + val = (area_res[0].number or 0) / 10000.0 dct_res[res_key].append(val) # TODO... res_keys = [('manday_realised', current_realisation_year_ope)] @@ -1701,7 +1701,11 @@ class OperationDashboard: .annotate(area=Sum('surface'))\ .order_by('scientist__attached_to__name').all() # TODO: man-days, man-days/hectare - dct_res[res_key] = org_res + + dct_res[res_key] = [] + for vals in org_res: + vals['area'] = (vals['area'] or 0) / 10000.0 + dct_res[res_key].append(vals) year_ope = Operation.objects.filter(**operation_type) res_keys = ['org_by_year'] @@ -1736,7 +1740,7 @@ class OperationDashboard: cost=Sum('cost')) years_dct = {} for yr in org_res.all(): - area = yr['area'] if yr['area'] else 0 + area = (yr['area'] if yr['area'] else 0) / 10000.0 cost = yr['cost'] if yr['cost'] else 0 years_dct[yr[key_date]] = (area, cost) r_years = [] @@ -1767,7 +1771,8 @@ class OperationDashboard: self.survey['effective'] = [] for yr in self.years: year_res = Operation.objects\ - .filter(scientist__isnull=False, year=yr)\ + .filter(scientist__isnull=False, year=yr, + operation_type__txt_idx__in=ope_types)\ .annotate(number=Sum('surface'), mean=Avg('surface')) nb = year_res[0].number if year_res.count() else 0 nb = nb if nb else 0 @@ -1839,9 +1844,12 @@ class OperationDashboard: dct_years = {} for v in vals: values = [] - for value in (v['number'], v['area'], v['cost'], - v['fnap']): - values.append(value if value else 0) + for k in ('number', 'area', 'cost', 'fnap'): + value = v[k] or 0 + if k == 'area': + value /= 10000.0 + values.append(value) + dct_years[v['operation__year']] = values years = [] for y in self.years: |