Commit 296260b3 authored by Edileuton Henrique de Oliveira's avatar Edileuton Henrique de Oliveira
Browse files

Merge branch 'master' of git:./proinfodata/unstable

parents 817ed1a2 ff465bc0
...@@ -15,7 +15,8 @@ CREATE TABLE proinfo_inventory ( ...@@ -15,7 +15,8 @@ CREATE TABLE proinfo_inventory (
disk2_model TEXT, disk2_model TEXT,
disk2_size INTEGER, disk2_size INTEGER,
disk2_used INTEGER, disk2_used INTEGER,
extra_hds SMALLINT DEFAULT 0 NOT NULL extra_hds SMALLINT DEFAULT 0 NOT NULL,
ts TIMESTAMP
); );
CREATE TABLE proinfo_net_usage ( CREATE TABLE proinfo_net_usage (
...@@ -48,7 +49,8 @@ CREATE TABLE rejected_inventory ( ...@@ -48,7 +49,8 @@ CREATE TABLE rejected_inventory (
disk2_model TEXT, disk2_model TEXT,
disk2_size INTEGER, disk2_size INTEGER,
disk2_used INTEGER, disk2_used INTEGER,
extra_hds SMALLINT extra_hds SMALLINT,
ts TIMESTAMP
); );
CREATE TABLE rejected_net_usage ( CREATE TABLE rejected_net_usage (
......
...@@ -16,7 +16,7 @@ CREATE TABLE dim_school ( ...@@ -16,7 +16,7 @@ CREATE TABLE dim_school (
inep CHARACTER VARYING(12) NOT NULL, inep CHARACTER VARYING(12) NOT NULL,
name CHARACTER VARYING(150) NOT NULL, name CHARACTER VARYING(150) NOT NULL,
address CHARACTER VARYING(100), address CHARACTER VARYING(100),
cep CHARACTER VARYING(10) cep CHARACTER VARYING(10),
CHECK (inep <> ''), CHECK (inep <> ''),
CHECK (name <> '') CHECK (name <> '')
); );
......
...@@ -6,6 +6,7 @@ CREATE TABLE fact_contact ( ...@@ -6,6 +6,7 @@ CREATE TABLE fact_contact (
dat_id DATE NOT NULL REFERENCES dim_date, dat_id DATE NOT NULL REFERENCES dim_date,
macaddr MACADDR NOT NULL, macaddr MACADDR NOT NULL,
project project_enum DEFAULT 'proinfo' NOT NULL, project project_enum DEFAULT 'proinfo' NOT NULL,
ts TIMESTAMP,
UNIQUE (sch_id, cit_id, dat_id, macaddr) UNIQUE (sch_id, cit_id, dat_id, macaddr)
); );
......
...@@ -49,6 +49,7 @@ BEGIN ...@@ -49,6 +49,7 @@ BEGIN
i.disk2_size, i.disk2_size,
i.disk2_used, i.disk2_used,
i.extra_hds, i.extra_hds,
i.ts,
'0'::boolean as valid '0'::boolean as valid
FROM FROM
proinfo_inventory i proinfo_inventory i
...@@ -189,11 +190,11 @@ BEGIN ...@@ -189,11 +190,11 @@ BEGIN
INSERT INTO rejected_inventory INSERT INTO rejected_inventory
(sch_id, cit_id, contact_date, project, inep, macaddr, (sch_id, cit_id, contact_date, project, inep, macaddr,
os_type, os_distro, os_kernel, processor, memory, disk1_model, os_type, os_distro, os_kernel, processor, memory, disk1_model,
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used) disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, ts)
(SELECT (SELECT
sch_id, cit_id, contact_date, project, inep, macaddr, sch_id, cit_id, contact_date, project, inep, macaddr,
os_type, os_distro, os_kernel, processor, memory, disk1_model, os_type, os_distro, os_kernel, processor, memory, disk1_model,
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, ts
FROM FROM
sa_inventory sa_inventory
WHERE WHERE
......
...@@ -15,10 +15,10 @@ BEGIN ...@@ -15,10 +15,10 @@ BEGIN
INTO result from sa_inventory; INTO result from sa_inventory;
-- --
INSERT INTO fact_contact (sch_id, cit_id, dat_id, macaddr, project) INSERT INTO fact_contact (sch_id, cit_id, dat_id, macaddr, project, ts)
(SELECT sch_id, cit_id, contact_date, macaddr::macaddr, to_project_enum(project) FROM sa_inventory WHERE valid = '1') (SELECT sch_id, cit_id, contact_date, macaddr::macaddr, to_project_enum(project), ts FROM sa_inventory WHERE valid = '1')
EXCEPT EXCEPT
(SELECT sch_id, cit_id, dat_id, macaddr, project FROM fact_contact WHERE dat_id >= result.min_date AND dat_id <= result.max_date); (SELECT sch_id, cit_id, dat_id, macaddr, project, ts FROM fact_contact WHERE dat_id >= result.min_date AND dat_id <= result.max_date);
-- how many rows were inserted? -- how many rows were inserted?
GET DIAGNOSTICS total_rows = ROW_COUNT; GET DIAGNOSTICS total_rows = ROW_COUNT;
......
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