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)
def projectTimes(slot_name, platform_name): #today = time.strftime("%Y-%m-%d") data = {} data["build"] = {} data["tests"] = {} projects = ProjNames.view('statistics/projectsInSlot', key=[today, slot_name]) for p in projects: data["projects"] = p.names for n in data["projects"]: data["build"][n] = {} data["tests"][n] = {} data["build"][n]['start_build'] = today + 'T' + '00:00:00' data["build"][n]['complet_build'] = today + 'T' + '00:00:00' data["tests"][n]['start_build'] = today + 'T' + '00:00:00' data["tests"][n]['complet_build'] = today + 'T' + '00:00:00' build_times = ProjectTimes.view( 'statistics/projectTimes', key=[slot_name, platform_name, today, "build-result"]) for t in build_times: data["build"][t.project]['start_build'] = today + 'T' + t.started data["build"][t.project]['complet_build'] = today + 'T' + t.completed tests_times = ProjectTimes.view( 'statistics/projectTimes', key=[slot_name, platform_name, today, "tests-result"]) for t in tests_times: data["tests"][t.project]['start_build'] = today + 'T' + t.started data["tests"][t.project]['complet_build'] = today + 'T' + t.completed data = json.dumps(data) return data
def projectTimes(slot_name,platform_name): #today = time.strftime("%Y-%m-%d") data = {} data["build"] = {} data["tests"] = {} projects = ProjNames.view('statistics/projectsInSlot',key=[today,slot_name]) for p in projects: data["projects"] = p.names for n in data["projects"]: data["build"][n]={} data["tests"][n]={} data["build"][n]['start_build'] = today+'T'+'00:00:00' data["build"][n]['complet_build'] = today+'T'+'00:00:00' data["tests"][n]['start_build'] = today+'T'+'00:00:00' data["tests"][n]['complet_build'] = today+'T'+'00:00:00' build_times = ProjectTimes.view('statistics/projectTimes',key=[slot_name,platform_name,today,"build-result"]) for t in build_times: data["build"][t.project]['start_build'] = today+'T'+t.started data["build"][t.project]['complet_build'] = today+'T'+t.completed tests_times = ProjectTimes.view('statistics/projectTimes',key=[slot_name,platform_name,today,"tests-result"]) for t in tests_times: data["tests"][t.project]['start_build'] = today+'T'+t.started data["tests"][t.project]['complet_build'] = today+'T'+t.completed data = json.dumps(data) return data