Beispiel #1
0
def iteration_time(request,iteration):
    its = get_iterations()
    it = [it for it in its if it[1]['name']==iteration][0]
    start_date = it[1]['start date'].date()
    end_date = it[1]['end date'].date()
    tf = get_fns(recurse=True)
    hours = [os.path.join(os.path.dirname(t),'hours.json') for t in tf]
    agg={} ; persons={} ; ptasks={}
    for h in hours:
        tid = '/'.join(os.path.dirname(h).split('/')[2:])
        if not os.path.exists(h): continue
        md = loadmeta(h)
        for stmp,data in md.items():
            stmp = datetime.datetime.strptime(stmp,'%Y-%m-%d').date()
            if not (stmp>=start_date and stmp<=end_date): continue
            for person,hours in data.items():
                if stmp not in agg: agg[stmp]={}
                if person not in agg[stmp]: agg[stmp][person]={}
                if person not in persons: persons[person]=0
                if person not in ptasks: ptasks[person]=[]
                persons[person]+=hours
                if tid not in ptasks[person]: ptasks[person].append(tid)
                if tid not in agg[stmp][person]: agg[stmp][person][tid]=0
                agg[stmp][person][tid]+=hours
    agg = list(agg.items())
    agg.sort(lambda i1,i2: cmp(i1[0],i2[0]))
    persons = list(persons.items())
    persons.sort(lambda i1,i2: cmp(i1[1],i2[1]),reverse=True)
    return {'persons':persons,'agg':agg,'it':it,'ptasks':ptasks,'request':request}
Beispiel #2
0
def iteration_commits(request,iteration,branch):
    gwu = cfg.GITWEB_URL
    its = get_iterations()
    it = [it for it in its if it[1]['name']==iteration][0]
    start_date = it[1]['start date']
    end_date = it[1]['end date']
    #print('commits on iteration %s to branch %s'%(iteration,branch))
    tf = get_fns(recurse=True)
    metas = [os.path.join(os.path.dirname(t),'meta.json') for t in tf]
    agg={} ; repos=[] ; task_data={} ; lastcommits={}
    
    for m in metas:
        tid = '/'.join(os.path.dirname(m).split('/')[2:])
        if not os.path.exists(m): continue
        md = loadmeta(m)
        if 'branchlastcommits' not in md: continue
        blc = md['branchlastcommits']

        for br,stmp in blc.items():
            if  '/' not in br:
                #print "%s has no /"%(br)
                continue
            try:
                repo,br = br.split('/')
            except ValueError:
                #print '%s has too many /'%(br)
                continue
            stmp = parsegitdate(stmp)
            if not (stmp.date()>=start_date.date() and stmp.date()<=end_date.date()):
                #print 'bad commit date %s'%stmp
                continue
            if not (branch=='all' or branch==br):
                #print 'branch mismatch %s<>%s'%(branch,br)
                continue
            if tid not in agg:
                agg[tid]={}
            if repo not in agg[tid]:
                agg[tid][repo]=[]
            agg[tid][repo].append(br)

            if tid not in task_data:
                t = get_task(tid)
                task_data[tid]=t

            if tid not in lastcommits: lastcommits[tid]=stmp
            if stmp>=lastcommits[tid]: lastcommits[tid]=stmp

            if repo not in repos: repos.append(repo)
            #print(tid,repo,br,stmp)
    agg = list(agg.items())
    def lcsort(i1,i2):
        return cmp(lastcommits[i1[0]],lastcommits[i2[0]])
    agg.sort(lcsort,reverse=True)
    return {'agg':agg,'it':it,'branch':branch,'repos':repos,'gwu':gwu,'task_data':task_data,'lastcommits':lastcommits,'request':request}