Commit 642569d6 authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue
Browse files

On évite les doublons dans le comptage.

parent 783ba04c
......@@ -20,6 +20,7 @@ from time import *
from gestion.config import NETs, plage_ens, prefix
from gestion.config import upload as upload
import gestion.config.encoding
import gestion.config.mails.upload as mails_upload
from gestion.ldap_crans import crans_ldap
from gestion.ldap_crans import MachineFixe
......@@ -79,8 +80,17 @@ def reperage_chambre(mac):
################################################################################
# upload par entité (adhérent/club/machine crans)
requete="""SELECT
SUM(agregat.total) as tot_upload, machines.type, machines.id
requete="""WITH
machines_sans_doublon
AS
(
SELECT DISTINCT ON(mac_addr)
*
FROM
machines
)
SELECT
SUM(agregat.total) as tot_upload, machines_sans_doublon.type, machines_sans_doublon.id
FROM (
SELECT
'upload', sum(bytes)/1024/1024 AS total, mac_src
......@@ -109,11 +119,11 @@ FROM (
mac_src
) AS agregat
INNER JOIN
machines
machines_sans_doublon
ON
machines.mac_addr = agregat.mac_src
machines_sans_doublon.mac_addr = agregat.mac_src
GROUP BY
machines.type, machines.id
machines_sans_doublon.type, machines_sans_doublon.id
ORDER BY
tot_upload;
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment