Commit 90b1895163e17b86ac662e08bc18fa1dfcdeeb05
1 parent
17b05589
Exists in
master
and in
4 other branches
New db method: charges by project for stacked data
Showing
1 changed file
with
48 additions
and
1 deletions
Show diff stats
app/db_mgr.py
... | ... | @@ -60,7 +60,6 @@ def charges_by_project(project_id): |
60 | 60 | where project_id = {project_id} |
61 | 61 | order by c.period_id |
62 | 62 | """ |
63 | - print(req_sql) | |
64 | 63 | req_res = db.session.execute(req_sql) |
65 | 64 | results = list(req_res) |
66 | 65 | # Remove comma |
... | ... | @@ -73,6 +72,54 @@ def charges_by_project(project_id): |
73 | 72 | return nocomma_results |
74 | 73 | |
75 | 74 | |
75 | +def charges_by_project_stacked(project_id, category="service"): | |
76 | + """ | |
77 | + Build the list of charges for one project, period by period | |
78 | + :param project_id: the project's id we want to return data for | |
79 | + :param category: what dict to build for each period, 'service' or 'capacity' ? | |
80 | + :return: a 2 dim table with header as first line and datas next, of the form | |
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, | |
84 | + . | |
85 | + . | |
86 | + sem_n, value_n0, value_n1, ....., value_nn, | |