Skip to content
Snippets Groups Projects
Commit 126ee75c authored by Diego Giovane Pasqualin's avatar Diego Giovane Pasqualin
Browse files

Add availability and net usage queries for gesac


The availability for now are just a copy from telecentros-br

Signed-off-by: default avatarDiego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
parent 83f8b266
No related branches found
No related tags found
No related merge requests found
SELECT
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability) AND
($1::text IS NULL OR region = $1::text) AND
($2::text IS NULL OR state = $2::text) AND
($3::text IS NULL OR city = $3::text);
\ No newline at end of file
SELECT
get_month_name(extract(month from base_date)::integer)::text AS month,
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability) AND
($1::text IS NULL OR region = $1::text) AND
($2::text IS NULL OR state = $2::text) AND
($3::text IS NULL OR city = $3::text)
GROUP BY
base_date
ORDER BY
base_date DESC
LIMIT 6;
\ No newline at end of file
SELECT
city AS cat,
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability) AND
($1::text IS NULL OR region = $1::text) AND
($2::text IS NULL OR state = $2::text)
GROUP BY
city;
SELECT
region AS cat,
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability)
GROUP BY
region;
SELECT
state AS cat,
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability) AND
($1::text IS NULL OR region = $1::text)
GROUP BY
state;
SELECT
tc_name AS cat,
SUM(is_green) AS green,
SUM(is_yellow) AS yellow,
SUM(is_red) AS red
FROM
aggr_availability
WHERE
base_date = (SELECT max(base_date) FROM aggr_availability) AND
($1::text IS NULL OR region = $1::text) AND
($2::text IS NULL OR state = $2::text) AND
($3::text IS NULL OR city = $3::text)
GROUP BY
tc_name;
SELECT
city AS cat
, AVG(bytes_five_min_to_kbits_sec(down)) AS down
, AVG(bytes_five_min_to_kbits_sec(up)) AS up
FROM
(SELECT
city
, id_city
, MAX(down_kbits) AS down
, MAX(up_kbits) AS up
FROM
fact_net_usage_convention
WHERE
state = $1::text
GROUP BY
city
, id_city
, id_point
) AS f
GROUP BY
city
, id_city
ORDER BY
city
;
-- Compute the peak for every telecenter and than the average for each region
SELECT
f.region AS cat
, AVG(bytes_five_min_to_kbits_sec(f.down)) AS down
, AVG(bytes_five_min_to_kbits_sec(f.up)) AS up
FROM
(SELECT
region
, MAX(down_kbits) AS down
, MAX(up_kbits) AS up
FROM
fact_net_usage_convention
GROUP BY
region
, id_point
) AS f
GROUP BY
f.region
ORDER BY
f.region
;
-- Compute the peak for every telecenter and than the average for each state
SELECT
state AS cat
, AVG(bytes_five_min_to_kbits_sec(down)) AS down
, AVG(bytes_five_min_to_kbits_sec(up)) AS up
FROM
(SELECT
state
, MAX(down_kbits) AS down
, MAX(up_kbits) AS up
FROM
fact_net_usage_convention
WHERE
region = $1::text
GROUP BY
state
, id_point
) AS f
GROUP BY
state
ORDER BY
state
;
SELECT
establishment AS cat
, id_point
, MAX(bytes_five_min_to_kbits_sec(down_kbits)) AS down
, MAX(bytes_five_min_to_kbits_sec(up_kbits)) AS up
FROM
fact_net_usage_convention
WHERE
city = $1::text
GROUP BY
id_point
, establishment
ORDER BY
establishment
;
SELECT
establishment AS cat
, bytes_five_min_to_kbits_sec(down_kbits) AS down
, bytes_five_min_to_kbits_sec(up_kbits) AS up
, collect_date + collect_time AS timestamp
FROM
fact_net_usage_convention
WHERE
id_point = $1::integer
ORDER BY
collect_date
, collect_time
;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment