Exemple #1
0
 def saveAll(self, userCountryStatisticsList):
     pgConn = pgConnector()
     values = ''
     for item in userCountryStatisticsList:
         values += "INSERT INTO {0}(date, userid, countrycode, country, count) VALUES ('{1}', '{2}', '{3}', '{4}', {5}) ON CONFLICT (date, userid, countrycode) DO UPDATE SET count = {0}.count + 1;".format(
             userCountryStatistics.USERCOUNTRYTABLE, item.date, item.userid,
             item.countrycode, item.country, 1)
     pgConn.execute_insert(values)
Exemple #2
0
 def save(self, userCountryStatistics):
     pgConn = pgConnector()
     pgConn.execute_insert(
         "INSERT INTO {0}(date, userid, countrycode, country, count) VALUES ('{1}', '{2}', '{3}', '{4}', {5}) ON CONFLICT (date, userid, countrycode) DO UPDATE SET count = {0}.count + 1"
         .format(userCountryStatistics.USERCOUNTRYTABLE,
                 userCountryStatistics.date, userCountryStatistics.userid,
                 userCountryStatistics.countrycode,
                 userCountryStatistics.country, 1))
 def saveAll(self, countryStatisticsList):
     pgConn = pgConnector()
     values = ''
     for item in countryStatisticsList:
         values += "INSERT INTO {0}(date, sourceidp, service, countrycode, country, count) VALUES ('{1}', '{2}', '{3}', '{4}', '{5}', {6}) ON CONFLICT (date, sourceidp, service, countrycode) DO UPDATE SET count = {0}.count + 1;".format(
             countryStatistics.STATISTICSTABLE, item.date, item.sourceIdp,
             item.service, item.countrycode, item.country, 1)
     pgConn.execute_insert(values)
 def save(self, countryStatistics):
     pgConn = pgConnector()
     pgConn.execute_insert(
         "INSERT INTO {0}(date, sourceidp, service, countrycode, country, count) VALUES ('{1}', '{2}', '{3}', '{4}', '{5}', {6}) ON CONFLICT (date, sourceidp, service, countrycode) DO UPDATE SET count = {0}.count + 1"
         .format(countryStatistics.STATISTICSTABLE, countryStatistics.date,
                 countryStatistics.sourceIdp, countryStatistics.service,
                 countryStatistics.countrycode, countryStatistics.country,
                 1))
Exemple #5
0
 def getAllIpStatistics(self):
   pgConn = pgConnector()
   result = list(pgConn.execute_select("SELECT accessed::date, sourceidp, service, userid, ip, ipversion FROM {0}".format(ipStatistics.IPSTATISTICSTABLE)))
   data = []
   for row in result:
     print(row[0])
     ipData = ipStatistics(row[0], row[1], row[2], row[3], row[4], row[5])
     data.append(ipData)
   return data
Exemple #6
0
 def getIpStatisticsByDate(self, dateFrom, dateTo):
   pgConn = pgConnector()
   
   result = list(pgConn.execute_select("SELECT accessed::date, sourceidp, service, userid, ip, ipversion FROM {0} WHERE accessed BETWEEN  '{1}' AND '{2}'".format(ipStatistics.IPSTATISTICSTABLE, dateFrom, dateTo)))
   data = []
   for row in result:
     #print(row)
     ipData = ipStatistics(row[0], row[1], row[2], row[3], row[4], row[5])
     data.append(ipData)
   return data
Exemple #7
0
 def getLastDate(self):
     pgConn = pgConnector()
     result = pgConn.execute_select(
         "SELECT max(date::date) FROM {0}".format(
             userCountryStatistics.USERCOUNTRYTABLE))
     return result
 def getLastDate(self):
     pgConn = pgConnector()
     result = pgConn.execute_select(
         "SELECT max(date::date) FROM {0}".format(
             countryStatistics.STATISTICSTABLE))
     return result