Skip to content
Snippets Groups Projects
Commit 19c1e7c5 authored by ayeaye's avatar ayeaye
Browse files

Collect milestones at the top, then gather rest of items by epic, and sort...

Collect milestones at the top, then gather rest of items by epic, and sort according to date -- TODO: subtasks?
parent 62c4b365
No related merge requests found
MILESTONE_OFFSET = 100000
EPIC_OFFSET = 200000
class ATTR:
COMPANY = ("mode", "company")
......
......@@ -60,7 +60,7 @@ def makeIssue(issue, isMilestone = False):
pass
if isMilestone:
parent = 0
parent = MILESTONE_OFFSET - 1
elif issue.milestone is None:
parent = 0
else:
......@@ -114,8 +114,8 @@ def makeIssue(issue, isMilestone = False):
try:
itemObj.epic = issue.epic.get("title")
itemObj.eid = issue.epic.get("id")
itemObj.pClass += f" epic{itemObj.eid}"
itemObj.eid = issue.epic.get("iid")
itemObj.trClass = f"gepic{itemObj.eid}"
except AttributeError:
pass
......@@ -128,9 +128,38 @@ def gantt(pid):
issues = []
for proj in grp.projects.list(all=True, as_list=False):
issues += projgantt( gl.projects.get(proj.id, lazy=True) )
return issues
except gitlab.exceptions.GitlabListError:
return projgantt( gl.projects.get(pid, lazy=True) )
issues = projgantt( gl.projects.get(pid, lazy=True) )
si = sorted([x for x in issues if "group" in x.pClass], key = lambda x: x.pStart)
si.insert(0, Dict(
pID = MILESTONE_OFFSET - 1,
pClass = "ggroupblack",
pName = "Milestones",
pStart = min((x.pStart for x in si if x.pStart != "None")),
pEnd = max((x.pEnd for x in si if x.pEnd != "None")),
pGroup = 1, pParent = 0, pOpen = 1,
))
epics = {}
for eid, epic in set(((x.eid or -1, x.epic or "Tasks not assigned to a subsystem")
for x in issues
if not x.pGroup)):
iss = sorted((x for x in issues if (x.eid or -1) == eid and "group" not in x.pClass), key = lambda x: x.pStart+x.pEnd)
pStart = min((x.pStart for x in iss if x.pStart != "None"))
pEnd = max((x.pEnd for x in iss if x.pEnd != "None"))
eio = Dict(
pID = eid + EPIC_OFFSET,
pClass = f"gtaskepic",
pName = epic,
pStart = pStart,
pEnd = pEnd,
trClass = f"gepic gepic{eid}",
)
if eid < 0: pStart = 0
epics[eid] = (f"{pStart}-{pEnd}-{eid}", [eio] + iss)
return si + sum(map(lambda x : x[1], sorted(epics.values())), start = [])
def projgantt(project):
issues = []
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment