Skip to content
Snippets Groups Projects
Commit 6cc70dcc authored by ayeaye's avatar ayeaye
Browse files

Refactor/cleanup issue attribute handling

parent 1efbbd90
No related merge requests found
......@@ -4,16 +4,14 @@ import logging
import json
from datetime import date, timedelta
from addict import Dict
from contextlib import suppress
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(SCRIPT_DIR)
from gl import *
def makeIssue(issue, isMilestone = False):
if "DELETED" in issue.title:
return None
def getDates(issue, isMilestone=False):
# XXX TODO: What about issues without a due_date?
try:
end = date.fromisoformat(issue.due_date)
......@@ -36,28 +34,31 @@ def makeIssue(issue, isMilestone = False):
else:
start = None
comp = 0
try:
return start, end
def getComp(issue):
with suppress(AttributeError):
if issue.state == "closed":
comp = 100
return 100
elif issue.task_completion_status["count"]:
comp = 100 * issue.task_completion_status["completed_count"] / issue.task_completion_status["count"]
except AttributeError:
pass
return 100 * issue.task_completion_status["completed_count"] / issue.task_completion_status["count"]
return 0
def makeIssue(issue, isMilestone = False):
if "DELETED" in issue.title:
return None
start, end = getDates(issue, isMilestone)
comp = getComp(issue)
cls = isMilestone and "ggroupblack" or "gtaskblue"
who = ""
try:
who = ", ".join((x["name"] for x in issue.assignees))
except AttributeError:
pass
with suppress(AttributeError): who = ", ".join((x["name"] for x in issue.assignees))
labels = ''
try:
labels = ", ".join(issue.labels)
except AttributeError:
pass
with suppress(AttributeError): labels = ", ".join(issue.labels)
if isMilestone:
parent = 0
......
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