diff --git a/statistiques/parseStats.py b/statistiques/parseStats.py index 1f5b48c..9b199fb 100755 --- a/statistiques/parseStats.py +++ b/statistiques/parseStats.py @@ -17,6 +17,7 @@ STATS_FR_TOT_FIELDS = ['conferences creees total','conferences totalement echoue STATS_AVG_FIELDS = ['largest_conference',] STATS_FR_AVG_FIELDS = ['plus grande conference',] dbPath = '/srv/visio.chapril.org/statistiques/stats_sqlite.db' +dbName = 'jitsi_stats' # Classes class Stats: @@ -83,8 +84,20 @@ class Stats: return octets,unit def parse2(self): - res = self.db.dbQuery(f"""SELECT * FROM {dbname} WHERE ts > {self.startDate} AND ts < {self.endDate}""") - return res + res = self.db.dbQuery(f"""SELECT * FROM {dbName} WHERE timestamp > {self.startDate} AND timestamp < {self.endDate}""") + consolided = {} + for line in res: + field = line[2] + if field in STATS_TOT_FIELDS: + if field in consolided: + consolided[field] = consolided[field] + int(line[3]) + else: + consolided[field] = int(line[3]) + if field in STATS_AVG_FIELDS: + if field in consolided: + if consolided[field] < int(line[3]): + consolided[field] = int(line[3]) + return consolided def parse(self): if len(self.files) <= 0: @@ -192,13 +205,16 @@ def runMain(): year = currentDate.year stats = Stats(year,mois) - res = stats.parse() + res = stats.parse2() for (k,v) in res.items(): - if k in STATS_TOT_FIELDS: - chaine = STATS_FR_TOT_FIELDS[STATS_TOT_FIELDS.index(k)] - elif k in STATS_AVG_FIELDS: - chaine = STATS_FR_AVG_FIELDS[STATS_AVG_FIELDS.index(k)] - print(f"{chaine} : {v}") + print(f"{k}={v}") + + #for (k,v) in res.items(): + # if k in STATS_TOT_FIELDS: + # chaine = STATS_FR_TOT_FIELDS[STATS_TOT_FIELDS.index(k)] + # elif k in STATS_AVG_FIELDS: + # chaine = STATS_FR_AVG_FIELDS[STATS_AVG_FIELDS.index(k)] + # print(f"{chaine} : {v}") if __name__ == '__main__': runMain()