コード例 #1
0
ファイル: stats_test.py プロジェクト: umfoida5/comp4350group5
 def test_function_calls(self):
 	self.testTotal = StatisticsEngine.total(StatsTest.mySE, "distance","Run",self.test_athlete.id,"1-1-1","1-1-1",None)
 	self.testAvg = StatisticsEngine.average(StatsTest.mySE, "distance","Run",self.test_athlete.id,"1-1-1","1-1-1",None)
 	self.testMin = StatisticsEngine.minimum(StatsTest.mySE, "distance","Run",self.test_athlete.id,"1-1-1","1-1-1",None)
 	self.testMax = StatisticsEngine.maximum(StatsTest.mySE, "distance","Run",self.test_athlete.id,"1-1-1","1-1-1",None)
 	
 	self.assertTrue("60" in str(self.testTotal))
 	self.assertTrue("20" in str(self.testAvg))
 	self.assertTrue("10" in str(self.testMin))
 	self.assertTrue("30" in str(self.testMax))
コード例 #2
0
ファイル: checkstats.py プロジェクト: umfoida5/comp4350group5
def get_completed(the_list, athlete_id):
    # TODO: replace these with static method calls
    engine = StatisticsEngine()    
    completed = []

    for element in the_list:
        result = None
        operator = element.operator.lower() # for easier comparison
        if operator == "total":
            result = engine.total(
                element.metric,
                element.activity,
                athlete_id,
                element.start_date,
                element.end_date,
                None
            )

        elif operator == "max":
            result = engine.maximum(
                element.metric,
                element.activity,
                athlete_id,
                element.start_date,
                element.end_date,
                None
            )

        elif operator == "min":
            result = engine.minimum(
                element.metric,
                element.activity,
                athlete_id,
                element.start_date,
                element.end_date,
                None
            )

        elif operator == "average":
            result = engine.average(
                element.metric,
                element.activity,
                athlete_id,
                element.start_date,
                element.end_date,
                None
            )
        else:
            raise

        # did we complete the element?
        if result[0].value >= element.quantity:
            completed.append(element)

    return completed
コード例 #3
0
ファイル: stats.py プロジェクト: umfoida5/comp4350group5
    def get_average(self, **params):
    	athlete = Athlete.query.filter_by(id = cherrypy.session.get('id')).one()
    	params['athlete_id'] = str(athlete.id)
     	result = StatisticsEngine.average(Stats.mySE, **params)
        the_object = []        
        for stat in result:
            dictionary = {"year":stat.year, "month":stat.month, "day":stat.day, "value":stat.value}
            the_object.append(dictionary)

    	return the_object