diff --git a/app/db_mgr.py b/app/db_mgr.py index e148152..bd1fa95 100644 --- a/app/db_mgr.py +++ b/app/db_mgr.py @@ -43,13 +43,19 @@ def projects(): # Build the table row by row for _pc in projects_charges: p_id = _pc[0] - p = Project.query.get(int(p_id)) + project = Project.query.get(int(p_id)) # adding 2 first columns: id, name - project_row = [p.id, p.name] + project_row = [project.id, project.name] # then labels, many for each category for category in categories: - # we build the labels.name list of the intersection of that category labels with projects labels - labels = [_cl.label.name for _cl in category.labels if _cl.label in [_pl.label for _pl in p.labels]] + # we build the labels.name list of the intersection of current category's labels with project's labels + # Comprehensive shortcut is: + # labels = [_cl.label.name for _cl in category.labels if _cl.label in [_pl.label for _pl in project.labels]] + # + category_labels = [_cl.label for _cl in category.labels] + project_labels = [_pl.label for _pl in project.labels] + intersection_labels = list(set.intersection(set(project_labels), set(category_labels))) + labels = [label.name for label in intersection_labels] project_row.append(labels) # then add total charge project_row.append(_pc[1]) -- libgit2 0.21.2