Exemple #1
0
def test_check(request,id,tid):
	#get controller api
	api=ControllerAPI(request)
	report=api.gettaskresults(tid)

	#if ready, get urls
	if report[0]["status"]=="complete":
		#get test case
		data=TestCase.get(id=id)

		#set data
		data.data=report[0]["result"]

		#if batch, prepare the reference items
		if data.batch is not None:
			for index in range(len(data.data)):
				#find the batch reference data for this item
				xmlitem=data.data[index]['meta.xmlitem']
				for batch in data.batch:
					if batch['merchant']['merchantId']==xmlitem['merchant']['merchantId'] and batch['merchantItemId']==xmlitem['merchantItemId']:
						#create merchantItem with values from the xml as reference
						item=MerchantItem()
						item.merchantItemTitle=xmlitem["merchantItemTitle"]	
						item.brand=xmlitem["brand"]	
						item.mpnValue=xmlitem["mpnValue"]
						item.item={"itemId":batch["item"]["itemId"]}
						data.data[index]["meta.refitem"]=item.to_dict()

		#update
		data.status=TestCase.STATUS_READY
		data.save()

	#return authentication
	return HttpResponse( AIResponse(data=data.data).serialize() )
Exemple #2
0
def system_report_test(request,id):
	def spread(match):
		diff=match["scores"][0]-(match["scores"][1] if len(match["scores"])>1 else 0)
		if len(match["scores"])>1:
			spread=diff/(float(sum(match["scores"][1:5]))/len(match["scores"][1:5]))
		else:
			spread=diff
		return spread

	#get controller api
	api=ControllerAPI(request)
	report=api.gettaskresults(id)

	#get stats
	stats={}
	for task in report:
		dataset=task["stats"]["test"]["matches"]

		#direct successful matches 
		stats["direct_success"]=[]

		#match score
		stats["direct_success"].append( [match["scores"][0] for match in dataset if (match["match"] is True and match["direct"] and match["success"]) ] )

		#2nd best score
		stats["direct_success"].append( [(match["scores"][1] if len(match["scores"])>1 else 0) for match in dataset if (match["match"] is True and match["direct"] and match["success"]) ] )


		#direct successful spread
		stats["direct_success_spread"]=[]

		#match spread
		stats["direct_success_spread"].append( [spread(match) for match in dataset if (match["match"] is True and match["direct"] and match["success"]) ] )


		#direct failed matches
		stats["direct_fail"]=[]

		#match score
		stats["direct_fail"].append( [match["scores"][0] for match in dataset if (match["match"] is True and match["direct"] and match["success"] is False) ] )

		#2nd best score
		stats["direct_fail"].append( [(match["scores"][1] if len(match["scores"])>1 else 0) for match in dataset if (match["match"] is True and match["direct"] and match["success"] is False) ] )

		#reference item score
		stats["direct_fail"].append( [match["ref"] for match in dataset if (match["match"] is True and match["direct"] and match["success"] is False) ] )


		#direct failed match spread
		stats["direct_fail_spread"]=[]

		#match spread
		stats["direct_fail_spread"].append( [spread(match) for match in dataset if (match["match"] is True and match["direct"] and match["success"] is False) ] )


        #template context
	context=_get_context(request,section="common",content="content_task_test",report=report,stats=stats)

	#render
        return HttpResponse( get_template('template_cpanel.html').render(Context(context)) )
Exemple #3
0
def system_report_results(request,id):
	#get controller api
	api=ControllerAPI(request)
	report=api.gettaskresults(id)

        #template context
	context=_get_context(request,section="admin",content="content_task_results",report=report)

	#render
        return HttpResponse( get_template('template_cpanel.html').render(Context(context)) )
Exemple #4
0
def training_check(request,id,tid):
	#get controller api
	api=ControllerAPI(request)
	report=api.gettaskresults(tid)

	#if ready, get urls
	if report[0]["status"]=="complete":
		#get ML data
		data=MLCase.get(id=id)

		#set data
		data.data=report[0]["result"]

		#update
		data.status=MLCase.STATUS_READY
		data.save()

	#return authentication
	return HttpResponse( AIResponse(data=data.data).serialize() )