Commit 9705f04bb25bbd655d49dd8527a27b71253e44ad
1 parent
de63cb72
Exists in
master
and in
4 other branches
Fix project charges sql request
now aggregating (sum) on the category (service or capacity)
Showing
1 changed file
with
7 additions
and
5 deletions
Show diff stats
app/db_mgr.py
... | ... | @@ -79,26 +79,28 @@ def charges_by_project_stacked(project_id, category="service"): |
79 | 79 | :param category: what dict to build for each period, 'service' or 'capacity' ? |
80 | 80 | :return: a 2 dim table with header as first line and datas next, of the form |
81 | 81 | period, category_0, category_1, ....., category_n, |
82 | - sem_0, value_00, value_01, ....., value_0n, | |
83 | - sem_1, value_10, value_11, ....., value_1n, | |
82 | + per_0, value_00, value_01, ....., value_0n, | |
83 | + per_1, value_10, value_11, ....., value_1n, | |
84 | 84 | . |
85 | 85 | . |
86 | - sem_n, value_n0, value_n1, ....., value_nn, | |
86 | + per_n, value_n0, value_n1, ....., value_nn, | |
87 | 87 | """ |
88 | 88 | if category == 'capacity': |
89 | 89 | category_table = 'capacity' |
90 | 90 | sql_req = """ |
91 | - select c.charge_rate | |
91 | + select sum(c.charge_rate) | |
92 | 92 | from capacity c1 left join |
93 | 93 | charge c on c1.id = c.capacity_id and project_id = {} and period_id={} |
94 | + group by c1.id | |
94 | 95 | order by c1.id |
95 | 96 | """ |
96 | 97 | elif category == 'service': |
97 | 98 | category_table = 'service' |
98 | 99 | sql_req = """ |
99 | - select c.charge_rate | |
100 | + select sum(c.charge_rate) | |
100 | 101 | from service s left join |
101 | 102 | charge c on s.id = c.service_id and project_id = {} and period_id={} |
103 | + group by s.id | |
102 | 104 | order by s.id |
103 | 105 | """ |
104 | 106 | else: | ... | ... |