示例#1
0
def create_bug_date_dict(bugs, initialdate, enddate):
    datelist = date_range_list(initialdate,enddate)
    datebugdict = initialize_date_bug_dict(datelist)


    print "len bugs:", len(bugs)
    for bug in bugs:
            # if created before initialdate, count only from initial date
        if bug.date.date() < initialdate:
            print "created date minor than initialdate, so take last one"
            startdate = initialdate
        else:
            startdate = bug.date.date()
        if bug.done: 
            print "bug is done"
            # if done before initialdate, don't count it
            if bug.log_modified.date() < initialdate:
                print "bug was done before initialdate, ignore it"
                break
            daterangeopen = date_range_list(startdate,bug.log_modified.date())[:-1]
            daterangedone = date_range_list(bug.log_modified.date(),enddate)
            if bug.severity in RC_SEVERITY:
               print "bug is rc"     
               # fill up previous dates with open     
               for d in daterangeopen:
                   datebugdict[d]['open_rc'] += 1
               # fill up next dates with close  
               for d in daterangedone:
                   datebugdict[d]['done_rc'] += 1
            else:
               print "bug is not rc"
               # fill up previous dates with open     
               for d in daterangeopen:
                   datebugdict[d]['open_other'] += 1
               # fill up next dates with close  
               for d in daterangedone:
                   datebugdict[d]['done_other'] += 1
        else:
            print "bug is open"
            daterange = date_range_list(startdate, enddate)
            if bug.severity in RC_SEVERITY:
               print "bug is rc"
               for d in daterange:
                   datebugdict[d]['open_rc'] += 1
            else:
               print "bug is not rc"
               for d in daterange:
                   datebugdict[d]['open_other'] += 1
    return datebugdict
示例#2
0
def bugs_by_person_by_date_dict(bugs, initialdate, enddate=None):
    """ Returns a dictionary where keys are dates and values are dictionaries 
    with persons as key and total number of open bugs as values.
    
    
    >>> bugs = load_bugs(os.path.join(basepath,'data','btshistory.pickle')
    >>> initialdate = datetime(2014,1,1).date()
    >>> datelist = date_range_list(initialdate)
    >>> bugsbypersonbydatedict = initialize_bugs_by_person_by_date_dict(datelist)
    >>> datepersondict = date_person_dict(bugs)
    >>> newbugsbypersonbydatedict = bugs_by_person_by_date_dict(datepersondict, 
    bugsbypersonbydatedict, initialdate)
    
    """

    if not enddate:
        enddate = date.today()

    datelist = date_range_list(initialdate)
    bugsbypersonbydatedict = initialize_bugs_by_person_by_date_dict(datelist)
    datepersondict = date_person_dict(bugs)
    totalbugsbyperson = initialize_bugs_by_person_dict(0, 'other')
    lastdatebugbyperson = initialize_bugs_by_person_dict(initialdate, 'other')


    for idate in sorted(bugsbypersonbydatedict.keys()):
        originator = datepersondict.get(idate, None)
        # if there's a bug open this day by somebody
        if originator:
            person = get_person_by_originator(originator)
            if totalbugsbyperson[person] > 0:
                # fill up the previous dates with the last number of bugs
                daterange = date_range_list(lastdatebugbyperson[person],  idate)
                for d in daterange:
                    bugsbypersonbydatedict[d][person] = totalbugsbyperson[person] 
            # update the current date
            totalbugsbyperson[person] +=1
            bugsbypersonbydatedict[idate][person]= totalbugsbyperson[person]
            lastdatebugbyperson[person] = idate
    #fill  up last dates to endate
    for person, lastdate in lastdatebugbyperson.items():
        daterange = date_range_list(lastdate, enddate)
        for d in daterange:
            bugsbypersonbydatedict[d][person] = totalbugsbyperson[person] 
    return bugsbypersonbydatedict