On étale les requêtes SQL pour la lisibilité
This commit is contained in:
parent
83a1a611ef
commit
64bb5252ea
1 changed files with 37 additions and 7 deletions
|
@ -43,10 +43,6 @@ for club in clubs:
|
|||
except:
|
||||
pass
|
||||
|
||||
requete = "SELECT * FROM signales WHERE date >= timestamp 'now' - interval '1 day';"
|
||||
cur.execute(requete)
|
||||
signales = cur.fetchall()
|
||||
|
||||
longueur = (24, 7)
|
||||
titres = (u'mac', u'chambres')
|
||||
alignements = ('c', 'c')
|
||||
|
@ -69,7 +65,20 @@ def genere_comptage(duree):
|
|||
global Logs
|
||||
pb_comptage_suspect = {}
|
||||
output = ""
|
||||
requete = "SELECT array_to_string(array_agg(DISTINCT date), ', ') AS dates , mac, array_to_string(array_agg(DISTINCT chambre), ', ') AS chambres, COUNT(DISTINCT chambre) AS nb_chambres_distinctes, COUNT(chambre) AS nb_chambres, COUNT(DISTINCT date) as nb_dates_distinctes, COUNT(DISTINCT mac) as nb_macs_distinctes FROM correspondance WHERE date >= timestamp 'now' - interval '%(delay)s' GROUP BY mac;" % {'delay': mac_prise.delay[duree]}
|
||||
requete = """SELECT
|
||||
array_to_string(array_agg(DISTINCT date), ', ') AS dates,
|
||||
mac,
|
||||
array_to_string(array_agg(DISTINCT chambre), ', ') AS chambres,
|
||||
COUNT(DISTINCT chambre) AS nb_chambres_distinctes,
|
||||
COUNT(chambre) AS nb_chambres,
|
||||
COUNT(DISTINCT date) AS nb_dates_distinctes,
|
||||
COUNT(DISTINCT mac) AS nb_macs_distinctes
|
||||
FROM
|
||||
correspondance
|
||||
WHERE
|
||||
date >= timestamp 'now' - interval '%(delay)s'
|
||||
GROUP BY
|
||||
mac;""" % {'delay': mac_prise.delay[duree]}
|
||||
cur.execute(requete)
|
||||
fetched = cur.fetchall()
|
||||
|
||||
|
@ -109,7 +118,15 @@ def summary():
|
|||
output = u""
|
||||
Logs = u""
|
||||
|
||||
requete = "SELECT * FROM spotted WHERE date >= timestamp 'now' - interval '1 day' ORDER BY date ASC;"
|
||||
requete = """SELECT
|
||||
*
|
||||
FROM
|
||||
spotted
|
||||
WHERE
|
||||
date >= timestamp 'now' - interval '1 day'
|
||||
ORDER BY
|
||||
date
|
||||
ASC;"""
|
||||
cur.execute(requete)
|
||||
fetched = cur.fetchall()
|
||||
liste_triee = collections.defaultdict(dict)
|
||||
|
@ -163,7 +180,20 @@ def reperage_mac_inconnue():
|
|||
|
||||
output = u""
|
||||
probleme = {}
|
||||
requete = "SELECT chambre, mac, COUNT(mac) as nb_min FROM correspondance WHERE date >= timestamp 'now' - interval '24 hours' GROUP BY chambre, mac ORDER BY chambre ASC;"
|
||||
requete = """SELECT
|
||||
chambre,
|
||||
mac,
|
||||
COUNT(mac) AS nb_min
|
||||
FROM
|
||||
correspondance
|
||||
WHERE
|
||||
date >= timestamp 'now' - interval '24 hours'
|
||||
GROUP BY
|
||||
chambre,
|
||||
mac
|
||||
ORDER BY
|
||||
chambre
|
||||
ASC;"""
|
||||
cur.execute(requete)
|
||||
fetched = cur.fetchall()
|
||||
liste_parsee = collections.defaultdict(dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue