diff --git a/app/db_mgr.py b/app/db_mgr.py index eaa0c34..d4a2b6d 100644 --- a/app/db_mgr.py +++ b/app/db_mgr.py @@ -79,26 +79,28 @@ def charges_by_project_stacked(project_id, category="service"): :param category: what dict to build for each period, 'service' or 'capacity' ? :return: a 2 dim table with header as first line and datas next, of the form period, category_0, category_1, ....., category_n, - sem_0, value_00, value_01, ....., value_0n, - sem_1, value_10, value_11, ....., value_1n, + per_0, value_00, value_01, ....., value_0n, + per_1, value_10, value_11, ....., value_1n, . . - sem_n, value_n0, value_n1, ....., value_nn, + per_n, value_n0, value_n1, ....., value_nn, """ if category == 'capacity': category_table = 'capacity' sql_req = """ - select c.charge_rate + select sum(c.charge_rate) from capacity c1 left join charge c on c1.id = c.capacity_id and project_id = {} and period_id={} + group by c1.id order by c1.id """ elif category == 'service': category_table = 'service' sql_req = """ - select c.charge_rate + select sum(c.charge_rate) from service s left join charge c on s.id = c.service_id and project_id = {} and period_id={} + group by s.id order by s.id """ else: -- libgit2 0.21.2