Example #1
0
def trimmedUNAIssue(issue):
    """Trim a UNA issue to just it's id and the number of hours and minutes
    since the last public xgen comment (the last time we've paid attention to
    it)."""
    now = datetime.utcnow()
    allComments = issue.doc['jira']['fields']['comment']['comments']
    lastComment = issue.lastXGenPublicComment
    if lastComment is None:
        lastUpdate = issue.updated
    elif lastComment['cidx'] == len(allComments) - 1:  # It's the last comment
        # Need when the issue was updated, not just created, so get all the
        # comment info
        lastUpdate = allComments[lastComment['cidx']]["updated"]
    else:
        # There has been at least one comment since the public xgen
        # comment, so if there are any customer comments, base timing off the
        # first one.
        lastUpdate = allComments[lastComment['cidx']]["updated"]
        i = lastComment['cidx'] + 1
        while i < len(allComments):
            if not isMongoDBEmail(allComments[i]['author']['emailAddress']):
                # It's a customer
                lastUpdate = allComments[i]["updated"]
                break
            i += 1
    mins = (now - lastUpdate).seconds / 60
    days = (now - lastUpdate).days
    return {
        "id": issue.doc["jira"]["key"],
        "priority": issue.priority,
        "assignee": issue.assigneeDisplayName,
        "days": days,
        "hours": mins / 60,
        "minutes": mins % 60
    }
Example #2
0
def trimmedUNAIssue(issue):
    """Trim a UNA issue to just it's id and the number of hours and minutes
    since the last public xgen comment (the last time we've paid attention to
    it)."""
    now = datetime.utcnow()
    allComments = issue.doc["jira"]["fields"]["comment"]["comments"]
    lastComment = issue.lastXGenPublicComment
    if lastComment is None:
        lastUpdate = issue.updated
    elif lastComment["cidx"] == len(allComments) - 1:  # It's the last comment
        # Need when the issue was updated, not just created, so get all the
        # comment info
        lastUpdate = allComments[lastComment["cidx"]]["updated"]
    else:
        # There has been at least one comment since the public xgen
        # comment, so if there are any customer comments, base timing off the
        # first one.
        lastUpdate = allComments[lastComment["cidx"]]["updated"]
        i = lastComment["cidx"] + 1
        while i < len(allComments):
            if not isMongoDBEmail(allComments[i]["author"]["emailAddress"]):
                # It's a customer
                lastUpdate = allComments[i]["updated"]
                break
            i += 1
    mins = (now - lastUpdate).seconds / 60
    days = (now - lastUpdate).days
    return {
        "id": issue.doc["jira"]["key"],
        "priority": issue.priority,
        "assignee": issue.assigneeDisplayName,
        "days": days,
        "hours": mins / 60,
        "minutes": mins % 60,
    }
Example #3
0
 def trimmedIssue(self, issue):
     """Trim the gen issue to a base set of fields TO BE DETERMINED."""
     now = datetime.utcnow()
     allComments = issue.doc['jira']['fields']['comment']['comments']
     lastComment = issue.lastXGenPublicComment
     if lastComment is None:
         lastUpdate = issue.updated.replace(tzinfo=None)
     elif lastComment['cidx'] == len(allComments) - 1:  # Its last comment
         # Need when the issue was updated, not just created so get all the
         # comment info
         lastUpdate = allComments[lastComment['cidx']]["updated"].\
             replace(tzinfo=None)
     else:
         # There has been at least one comment since the public xgen
         # comment, so if there are any customer comments, base timing
         # off of the first one.
         lastUpdate = allComments[lastComment['cidx']]["updated"].\
             replace(tzinfo=None)
         i = lastComment['cidx'] + 1
         while i < len(allComments):
             eml = 'emailAddress'
             if not isMongoDBEmail(allComments[i]['author'][eml]):
                 # It's a customer
                 lastUpdate = allComments[i]["updated"].\
                     replace(tzinfo=None)
                 break
             i += 1
     mins = (now - lastUpdate).seconds / 60
     days = (now - lastUpdate).days
     return {"id": issue.doc["jira"]["key"],
             "priority": issue.priority,
             "assignee": issue.assigneeDisplayName,
             "days": days,
             "hours": mins / 60,
             "minutes": mins % 60,
             "desc": issue.doc['jira']['fields']['summary']}