calculerToutResume.py 1.39 KB
Newer Older
JonathanMM's avatar
JonathanMM committed
1
from resumeLib import debuterCalculResume, debuterCalculResumeConso, debuterCalculResumeOfResume, debuterCalculResumeOfResumeConso
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import pymysql, datetime
from config import getMysqlConnection

#On commence par avoir la date min et max
mysql = getMysqlConnection()
requete = mysql.cursor()
requete.execute("SELECT MIN(date), MAX(date) FROM `statusConso`")
bornesDate = requete.fetchone()
dateMin = bornesDate[0].replace(microsecond = 0, second = 0)
dateMax = bornesDate[1].replace(microsecond = 0, second = 0)

print("******* Bornes *******")
print("Début = "+str(dateMin))
print("Fin = "+str(dateMax))
print("******* Bornes *******")

#Périodes à calculer
periodes = [5, 15, 60, 360]
periodePrecedente = 0
for periode in periodes:
    dateCourante = dateMin
    print("-> Début période "+ str(periode))
    while dateCourante + datetime.timedelta(minutes=periode) <= dateMax:
        print("Période " + str(periode)+'; date = '+str(dateCourante))
        if periode == 5:
            debuterCalculResume(periode, dateCourante)
JonathanMM's avatar
JonathanMM committed
28
            debuterCalculResumeConso(periode, dateCourante)
29 30
        else:
            debuterCalculResumeOfResume(periodePrecedente, periode, dateCourante)
JonathanMM's avatar
JonathanMM committed
31
            debuterCalculResumeOfResumeConso(periodePrecedente, periode, dateCourante)
32 33 34
        dateCourante = dateCourante + datetime.timedelta(minutes=periode)
    periodePrecedente = periode
    print("-> Fin période "+ str(periode))