On évite les doublons dans le comptage.
This commit is contained in:
parent
783ba04cd3
commit
642569d6a5
1 changed files with 15 additions and 5 deletions
|
@ -20,6 +20,7 @@ from time import *
|
||||||
|
|
||||||
from gestion.config import NETs, plage_ens, prefix
|
from gestion.config import NETs, plage_ens, prefix
|
||||||
from gestion.config import upload as upload
|
from gestion.config import upload as upload
|
||||||
|
import gestion.config.encoding
|
||||||
import gestion.config.mails.upload as mails_upload
|
import gestion.config.mails.upload as mails_upload
|
||||||
from gestion.ldap_crans import crans_ldap
|
from gestion.ldap_crans import crans_ldap
|
||||||
from gestion.ldap_crans import MachineFixe
|
from gestion.ldap_crans import MachineFixe
|
||||||
|
@ -79,8 +80,17 @@ def reperage_chambre(mac):
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# upload par entité (adhérent/club/machine crans)
|
# upload par entité (adhérent/club/machine crans)
|
||||||
requete="""SELECT
|
requete="""WITH
|
||||||
SUM(agregat.total) as tot_upload, machines.type, machines.id
|
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 (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
'upload', sum(bytes)/1024/1024 AS total, mac_src
|
'upload', sum(bytes)/1024/1024 AS total, mac_src
|
||||||
|
@ -109,11 +119,11 @@ FROM (
|
||||||
mac_src
|
mac_src
|
||||||
) AS agregat
|
) AS agregat
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
machines
|
machines_sans_doublon
|
||||||
ON
|
ON
|
||||||
machines.mac_addr = agregat.mac_src
|
machines_sans_doublon.mac_addr = agregat.mac_src
|
||||||
GROUP BY
|
GROUP BY
|
||||||
machines.type, machines.id
|
machines_sans_doublon.type, machines_sans_doublon.id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
tot_upload;
|
tot_upload;
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue