当前位置: 首页>>代码示例>>Python>>正文


Python Job.view方法代码示例

本文整理汇总了Python中models.Job.view方法的典型用法代码示例。如果您正苦于以下问题:Python Job.view方法的具体用法?Python Job.view怎么用?Python Job.view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Job的用法示例。


在下文中一共展示了Job.view方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: todayStats

# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import view [as 别名]
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
开发者ID:sofiaqiriazi,项目名称:StatisticsApp,代码行数:54,代码来源:statistics.py


注:本文中的models.Job.view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。