Ejemplo n.º 1
0
def before_request():
	g.db = connect_db()
	Slot_Conf.set_db(g.db)
	Job.set_db(g.db) 
	TimeInfo.set_db(g.db)
	slotStartEnd.set_db(g.db)
	Projects.set_db(g.db)
	Results.set_db(g.db)
	ProjNames.set_db(g.db)
	SlotTimes.set_db(g.db)
	ProjectTimes.set_db(g.db)
Ejemplo n.º 2
0
def before_request():
    g.db = connect_db()
    Slot_Conf.set_db(g.db)
    Job.set_db(g.db)
    TimeInfo.set_db(g.db)
    slotStartEnd.set_db(g.db)
    Projects.set_db(g.db)
    Results.set_db(g.db)
    ProjNames.set_db(g.db)
    SlotTimes.set_db(g.db)
    ProjectTimes.set_db(g.db)
Ejemplo n.º 3
0
def slotsTimes():

	#today = time.strftime("%Y-%m-%d")
	 
        slotsendtimes  = slotStartEnd.view('statistics/slotsTimes',key = [today,"job-end"])
        slotsstarttimes = slotStartEnd.view('statistics/slotsTimes',key = [today,"job-start"])
        data = {}

        slots = Slot_Conf.view('statistics/Slots',key=today)

        for s in slots:
	        	
                data[s.slot]={}
                for p in s.platforms:
                        data[s.slot][p]={}
                        data[s.slot][p]['start'] = 0
                        data[s.slot][p]['end'] = 0

        for s in slotsendtimes:
                data[s.slot][s.platform]['end'] = s.seconds
        for s in slotsstarttimes:
                data[s.slot][s.platform]['start'] = s.seconds


        data = json.dumps(data)

        return data
Ejemplo n.º 4
0
def slotsTimes():

    #today = time.strftime("%Y-%m-%d")

    slotsendtimes = slotStartEnd.view('statistics/slotsTimes',
                                      key=[today, "job-end"])
    slotsstarttimes = slotStartEnd.view('statistics/slotsTimes',
                                        key=[today, "job-start"])
    data = {}

    slots = Slot_Conf.view('statistics/Slots', key=today)

    for s in slots:

        data[s.slot] = {}
        for p in s.platforms:
            data[s.slot][p] = {}
            data[s.slot][p]['start'] = 0
            data[s.slot][p]['end'] = 0

    for s in slotsendtimes:
        data[s.slot][s.platform]['end'] = s.seconds
    for s in slotsstarttimes:
        data[s.slot][s.platform]['start'] = s.seconds

    data = json.dumps(data)

    return data
Ejemplo n.º 5
0
def slotTimeInfo(slot_name):

    #today = time.strftime("%Y-%m-%d")
    yesterday = '2014-08-14'
    preyesterday = '2014-08-13'

    #yesterday = (date.today()-timedelta(1)).strftime('%Y-%m-%d')
    #preyesterday = (date.today()-timedelta(2)).strftime('%Y-%m-%d')

    slotsendtimes = SlotTimes.view('statistics/slotTimeInfo',
                                   key=[today, slot_name, "job-end"])
    slotsstarttimes = SlotTimes.view('statistics/slotTimeInfo',
                                     key=[today, slot_name, "job-start"])
    data = {}

    slots = Slot_Conf.view('statistics/Slots', key=today)

    for s in slots:
        if s.slot == slot_name:
            data[s.slot] = {}
            for p in s.platforms:
                data[s.slot][p] = {}
                data[s.slot][p]['start'] = ""
                data[s.slot][p]['end'] = ""
                data[s.slot][p]['avgcompletion'] = 0

    for s in slotsendtimes:
        data[s.slot][s.platform]['end'] = s.time
    for s in slotsstarttimes:
        data[s.slot][s.platform]['start'] = s.time

    slotendtimes = SlotTimes.view('statistics/slotTimeInfo',
                                  key=[yesterday, slot_name, "job-end"])
    for s in slotendtimes:
        data[s.slot][s.platform]['avgcompletion'] += getSec(s.time)

    slotstarttimes = SlotTimes.view('statistics/slotTimeInfo',
                                    key=[yesterday, slot_name, "job-start"])
    for s in slotstarttimes:
        data[s.slot][s.platform]['avgcompletion'] -= getSec(s.time)

    slotendtimes = SlotTimes.view('statistics/slotTimeInfo',
                                  key=[preyesterday, slot_name, "job-end"])
    for s in slotendtimes:
        data[s.slot][s.platform]['avgcompletion'] += getSec(s.time)

    slotstarttimes = SlotTimes.view('statistics/slotTimeInfo',
                                    key=[preyesterday, slot_name, "job-start"])
    for s in slotstarttimes:
        data[s.slot][s.platform]['avgcompletion'] -= getSec(s.time)
        data[s.slot][s.platform]['avgcompletion'] /= 2

    data = json.dumps(data)
    return data
Ejemplo n.º 6
0
def todayStats():
        slots = []
	#today = time.strftime("%Y-%m-%d")
	 
	#weekbefore = (date.today()-timedelta(6)).strftime('%Y-%m-%d')
	jobEnds = Job.view('statistics/jobEnds',group_level=3,startkey = [today])
        jobStarts = Job.view('statistics/jobStarts',group_level=3,startkey = [today])
        slots = Slot_Conf.view('statistics/Slots',startkey = today)
        times = TimeInfo.view('statistics/completionTime',group = True, startkey = weekbefore)
        data = []
        jobsEnded = {}	
        jobsStarted = {}

	for s in slots:
		jobsEnded[s.slot] = 0
		jobsStarted[s.slot] = 0

        for j in jobEnds:
                jobsEnded[j['key'][1]]=j['value']

        for j in jobStarts:
                jobsStarted[j['key'][1]]=j['value']

        unfinished = 0
        unstarted = 0
        unfinished_list = []
        unstarted_list = []
        completed_list = []
        for s in slots:
                if(jobsEnded[s.slot]!=len(s.platforms)):
                        unfinished+=1
                        unfinished_list.append(s.slot)
                if(jobsStarted[s.slot]!=len(s.platforms)):
                        unstarted+=1
                        unstarted_list.append(s.slot)
                if(jobsStarted[s.slot]==len(s.platforms) and jobsEnded[s.slot]==len(s.platforms)):
                        completed_list.append(s.slot)
        sum = 0
        for t in times:
                if t['key']==today:
                        todaymin = t['value']['min']
                        sum = sum - (t['value']['max'] - t['value']['min'])
                sum = sum + (t['value']['max'] - t['value']['min'])

        avgcompletion = sum/6
        data = []
        all_list = unfinished_list+unstarted_list+completed_list
        data.append({"total":len(slots),"all":all_list,"finished":len(slots)-unfinished,"unfinished":unfinished,"unstarted":unstarted,"todaymin":todaymin,"avgcompletion":avgcompletion,"listofunfinished":unfinished_list,"listofunstarted":unstarted_list,"listofcompleted":completed_list})

        data =json.dumps(data)
   
	return data
Ejemplo n.º 7
0
def slotTimeInfo(slot_name): 

	#today = time.strftime("%Y-%m-%d")
	yesterday = '2014-08-14'
	preyesterday = '2014-08-13'
	

	#yesterday = (date.today()-timedelta(1)).strftime('%Y-%m-%d')
	#preyesterday = (date.today()-timedelta(2)).strftime('%Y-%m-%d')
	
 
        slotsendtimes  = SlotTimes.view('statistics/slotTimeInfo',key = [today,slot_name,"job-end"]) 
        slotsstarttimes = SlotTimes.view('statistics/slotTimeInfo',key = [today,slot_name,"job-start"]) 
        data = {} 
 
        slots = Slot_Conf.view('statistics/Slots',key=today) 
 
        for s in slots: 
                if s.slot == slot_name: 
                        data[s.slot]={} 
                        for p in s.platforms: 
                                data[s.slot][p]={} 
                                data[s.slot][p]['start'] = "" 
                                data[s.slot][p]['end'] = "" 
                                data[s.slot][p]['avgcompletion'] = 0 
                 
        for s in slotsendtimes: 
                data[s.slot][s.platform]['end'] = s.time 
        for s in slotsstarttimes: 
                data[s.slot][s.platform]['start'] = s.time       
 
        slotendtimes = SlotTimes.view('statistics/slotTimeInfo',key = [yesterday,slot_name,"job-end"]) 
        for s in slotendtimes: 
                data[s.slot][s.platform]['avgcompletion']+=getSec(s.time)
	
	slotstarttimes = SlotTimes.view('statistics/slotTimeInfo',key = [yesterday,slot_name,"job-start"]) 
        for s in slotstarttimes: 
                data[s.slot][s.platform]['avgcompletion']-=getSec(s.time) 
		 
	slotendtimes = SlotTimes.view('statistics/slotTimeInfo',key = [preyesterday,slot_name,"job-end"]) 
        for s in slotendtimes: 
                data[s.slot][s.platform]['avgcompletion']+=getSec(s.time)
	
	slotstarttimes = SlotTimes.view('statistics/slotTimeInfo',key = [preyesterday,slot_name,"job-start"]) 
        for s in slotstarttimes: 
                data[s.slot][s.platform]['avgcompletion']-=getSec(s.time) 
                data[s.slot][s.platform]['avgcompletion']/=2
	

         
        data = json.dumps(data);         
        return data
Ejemplo n.º 8
0
def slotInfo():

    slots = []
    #today = time.strftime("%Y-%m-%d")
    slots = Slot_Conf.view('statistics/Slots', key=today)

    slats = []
    for s in slots:
        slats.append({"slot": s.slot, "plats": s.platforms})

    slats = json.dumps(slats)

    return slats
Ejemplo n.º 9
0
def slotInfo(): 
	
        slots = []
	#today = time.strftime("%Y-%m-%d") 
        slots = Slot_Conf.view('statistics/Slots',key = today)         
 
                 
        slats = [] 
        for s in slots: 
                slats.append({"slot":s.slot,"plats":s.platforms}) 
 
        slats = json.dumps(slats)        
 
        return slats
Ejemplo n.º 10
0
def slotsResults(slot_name):
	
	#today = time.strftime("%Y-%m-%d")
	 
        slots = Slot_Conf.view('statistics/Slots',key=today)
        projects = ProjNames.view('statistics/projectsInSlot',key=[today,slot_name])
        results = Results.view('statistics/slotsResults',key=[today,slot_name])

        platforms = []
        for s in slots:
                if s.slot==slot_name:
                        platforms = s.platforms

        dopedict = {}
        for p in platforms:
                dopedict[p] = {}
                dopedict[p]['tests-result'] = []
                dopedict[p]['build-result'] = []

        for r in results:
                dopedict[r.platform][r.set].append(r.project)

        for n in projects:
                names = n.names
        
	keys = dict((n,k) for k,n in enumerate(names))

        for p in platforms:
                dopedict[p]['tests-missing'] = filter(lambda x: x not in dopedict[p]['tests-result'],names)
                dopedict[p]['build-missing'] = filter(lambda x: x not in dopedict[p]['build-result'],names)

        resultsdict = {}
        resultsdict['unstarted']=[]
        resultsdict['unfinished']=[]
        for p in platforms:
                resultsdict['unstarted' ]+=dopedict[p]['build-missing']
                resultsdict['unfinished']+=dopedict[p]['tests-missing']

        finished = sorted(set(names)-set(resultsdict['unfinished']), key=keys.get)
        unstarted = list(set(resultsdict['unstarted']))
        unfinished = list(set(resultsdict['unfinished'])-set(resultsdict['unstarted']))

        data=[]
        data.append({"total":len(results),"projects":names,"slot":slot_name,"platforms":platforms,"dopedict":dopedict,"unstarted":unstarted,"unfinished":unfinished,"finished":finished})
        data = json.dumps(data)

        return data
Ejemplo n.º 11
0
def slotResult(slot_name):

    slots = Slot_Conf.view('statistics/Slots', key=today)
    projects = ProjNames.view('statistics/projectsInSlot',
                              key=[today, slot_name])
    results = Results.view('statistics/slotsResults', key=[today, slot_name])

    platforms = []
    for s in slots:
        if s.slot == slot_name:
            platforms = s.platforms

    for p in projects:
        names = p.names

    dopedict = {}
    for p in platforms:
        dopedict[p] = {}
        dopedict[p]['tests-result'] = []
        dopedict[p]['build-result'] = []

    data = {}

    for n in names:
        data[n] = {}
        for p in platforms:
            data[n][p] = {}
            data[n][p]['tests-result'] = {
                "started": today + "T" + "00:00:00",
                "completed": today + "T" + "00:00:00"
            }
            data[n][p]['build-result'] = {
                "started": today + "T" + "00:00:00",
                "completed": today + "T" + "00:00:00"
            }

    for r in results:
        data[r.project][r.platform][r.set] = {
            "started": r.started,
            "completed": r.completed
        }

    data = json.dumps(data)
    return data
Ejemplo n.º 12
0
def slotResult(slot_name):

        slots = Slot_Conf.view('statistics/Slots',key=today)
        projects = ProjNames.view('statistics/projectsInSlot',key=[today,slot_name])
        results = Results.view('statistics/slotsResults',key=[today,slot_name])

        platforms = []
        for s in slots:
                if s.slot==slot_name:
                        platforms = s.platforms

	for p in projects:
		names = p.names

        dopedict = {}
        for p in platforms:
                dopedict[p] = {}
                dopedict[p]['tests-result'] = []
                dopedict[p]['build-result'] = []

	data = {}

	for n in names:
		data[n] = {}
		for p in platforms:
			data[n][p]={}
			data[n][p]['tests-result']={"started":today+"T"+"00:00:00","completed":today+"T"+"00:00:00"}
			data[n][p]['build-result']={"started":today+"T"+"00:00:00","completed":today+"T"+"00:00:00"}
		
		
        for r in results:
		data[r.project][r.platform][r.set]={"started":r.started,"completed":r.completed}

			
        data = json.dumps(data)
	return data
Ejemplo n.º 13
0
def todayStats():
    slots = []
    #today = time.strftime("%Y-%m-%d")

    #weekbefore = (date.today()-timedelta(6)).strftime('%Y-%m-%d')
    jobEnds = Job.view('statistics/jobEnds', group_level=3, startkey=[today])
    jobStarts = Job.view('statistics/jobStarts',
                         group_level=3,
                         startkey=[today])
    slots = Slot_Conf.view('statistics/Slots', startkey=today)
    times = TimeInfo.view('statistics/completionTime',
                          group=True,
                          startkey=weekbefore)
    data = []
    jobsEnded = {}
    jobsStarted = {}

    for s in slots:
        jobsEnded[s.slot] = 0
        jobsStarted[s.slot] = 0

    for j in jobEnds:
        jobsEnded[j['key'][1]] = j['value']

    for j in jobStarts:
        jobsStarted[j['key'][1]] = j['value']

    unfinished = 0
    unstarted = 0
    unfinished_list = []
    unstarted_list = []
    completed_list = []
    for s in slots:
        if (jobsEnded[s.slot] != len(s.platforms)):
            unfinished += 1
            unfinished_list.append(s.slot)
        if (jobsStarted[s.slot] != len(s.platforms)):
            unstarted += 1
            unstarted_list.append(s.slot)
        if (jobsStarted[s.slot] == len(s.platforms)
                and jobsEnded[s.slot] == len(s.platforms)):
            completed_list.append(s.slot)
    sum = 0
    for t in times:
        if t['key'] == today:
            todaymin = t['value']['min']
            sum = sum - (t['value']['max'] - t['value']['min'])
        sum = sum + (t['value']['max'] - t['value']['min'])

    avgcompletion = sum / 6
    data = []
    all_list = unfinished_list + unstarted_list + completed_list
    data.append({
        "total": len(slots),
        "all": all_list,
        "finished": len(slots) - unfinished,
        "unfinished": unfinished,
        "unstarted": unstarted,
        "todaymin": todaymin,
        "avgcompletion": avgcompletion,
        "listofunfinished": unfinished_list,
        "listofunstarted": unstarted_list,
        "listofcompleted": completed_list
    })

    data = json.dumps(data)

    return data
Ejemplo n.º 14
0
def slotsResults(slot_name):

    #today = time.strftime("%Y-%m-%d")

    slots = Slot_Conf.view('statistics/Slots', key=today)
    projects = ProjNames.view('statistics/projectsInSlot',
                              key=[today, slot_name])
    results = Results.view('statistics/slotsResults', key=[today, slot_name])

    platforms = []
    for s in slots:
        if s.slot == slot_name:
            platforms = s.platforms

    dopedict = {}
    for p in platforms:
        dopedict[p] = {}
        dopedict[p]['tests-result'] = []
        dopedict[p]['build-result'] = []

    for r in results:
        dopedict[r.platform][r.set].append(r.project)

    for n in projects:
        names = n.names

    keys = dict((n, k) for k, n in enumerate(names))

    for p in platforms:
        dopedict[p]['tests-missing'] = filter(
            lambda x: x not in dopedict[p]['tests-result'], names)
        dopedict[p]['build-missing'] = filter(
            lambda x: x not in dopedict[p]['build-result'], names)

    resultsdict = {}
    resultsdict['unstarted'] = []
    resultsdict['unfinished'] = []
    for p in platforms:
        resultsdict['unstarted'] += dopedict[p]['build-missing']
        resultsdict['unfinished'] += dopedict[p]['tests-missing']

    finished = sorted(set(names) - set(resultsdict['unfinished']),
                      key=keys.get)
    unstarted = list(set(resultsdict['unstarted']))
    unfinished = list(
        set(resultsdict['unfinished']) - set(resultsdict['unstarted']))

    data = []
    data.append({
        "total": len(results),
        "projects": names,
        "slot": slot_name,
        "platforms": platforms,
        "dopedict": dopedict,
        "unstarted": unstarted,
        "unfinished": unfinished,
        "finished": finished
    })
    data = json.dumps(data)

    return data