produits
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
image: iut/pgsql:2025-10
|
image: iut/pgsql:2025-11
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=fr-FR"
|
POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=fr-FR"
|
||||||
POSTGRES_DB: ${COMPOSE_PROJECT_NAME}
|
POSTGRES_DB: ${COMPOSE_PROJECT_NAME}
|
||||||
|
|||||||
8002
data/produit.csv
Normal file
8002
data/produit.csv
Normal file
File diff suppressed because it is too large
Load Diff
@@ -58,46 +58,3 @@ create table region (
|
|||||||
|
|
||||||
insert into region values
|
insert into region values
|
||||||
(1, 'Est'), (2, 'Ouest');
|
(1, 'Est'), (2, 'Ouest');
|
||||||
|
|
||||||
create table produit (
|
|
||||||
id bigint null,
|
|
||||||
nom text not null,
|
|
||||||
marque text null,
|
|
||||||
categorie text null,
|
|
||||||
energie int not null,
|
|
||||||
proteines float4 null,
|
|
||||||
glucide float4 null,
|
|
||||||
sucre float4 null,
|
|
||||||
graisse float4 null,
|
|
||||||
graisse_saturee float4 null,
|
|
||||||
sel float4 null,
|
|
||||||
fibres float4 null,
|
|
||||||
nutriscore int null,
|
|
||||||
additifs int null,
|
|
||||||
additifs_list text[] null,
|
|
||||||
potassium float null,
|
|
||||||
calcium float null,
|
|
||||||
magnesium float null,
|
|
||||||
sodium float null,
|
|
||||||
chlorure float null,
|
|
||||||
sulfate float null,
|
|
||||||
nitrate float null,
|
|
||||||
hydrogenocarbonate float null,
|
|
||||||
silice float null,
|
|
||||||
fluor float null,
|
|
||||||
residu float null,
|
|
||||||
ph float null,
|
|
||||||
vitamin_a float null,
|
|
||||||
vitamin_c float null
|
|
||||||
);
|
|
||||||
|
|
||||||
comment on column produit.potassium IS 'K⁺ en mg/L';
|
|
||||||
comment on column produit.calcium IS 'Ca²⁺ en mg/L';
|
|
||||||
comment on column produit.magnesium IS 'Mg²⁺ en mg/L';
|
|
||||||
comment on column produit.sodium IS 'Na⁺ en mg/L';
|
|
||||||
comment on column produit.chlorure IS 'Cl⁻ en mg/L';
|
|
||||||
comment on column produit.sulfate IS 'SO₄²⁻ en mg/L';
|
|
||||||
comment on column produit.nitrate IS 'NO₃⁻ en mg/L';
|
|
||||||
comment on column produit.hydrogenocarbonate IS 'HCO₃⁻ en mg/L';
|
|
||||||
comment on column produit.silice IS 'SiO₂ en mg/L';
|
|
||||||
comment on column produit.fluor IS 'F en mg/L';
|
|
||||||
|
|||||||
44
docker-entrypoint-initdb.d/6_produit.sql
Normal file
44
docker-entrypoint-initdb.d/6_produit.sql
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
create table produit (
|
||||||
|
id bigint primary key,
|
||||||
|
nom text not null,
|
||||||
|
marque text null,
|
||||||
|
categorie text null,
|
||||||
|
energie int not null,
|
||||||
|
proteines float4 null,
|
||||||
|
glucide float4 null,
|
||||||
|
sucre float4 null,
|
||||||
|
graisse float4 null,
|
||||||
|
graisse_saturee float4 null,
|
||||||
|
sel float4 null,
|
||||||
|
fibres float4 null,
|
||||||
|
nutriscore int null,
|
||||||
|
additifs int null,
|
||||||
|
additifs_list text[] null,
|
||||||
|
potassium float null,
|
||||||
|
calcium float null,
|
||||||
|
magnesium float null,
|
||||||
|
sodium float null,
|
||||||
|
chlorure float null,
|
||||||
|
sulfate float null,
|
||||||
|
nitrate float null,
|
||||||
|
hydrogenocarbonate float null,
|
||||||
|
silice float null,
|
||||||
|
fluor float null,
|
||||||
|
residu float null,
|
||||||
|
ph float null,
|
||||||
|
vitamin_a float null,
|
||||||
|
vitamin_c float null
|
||||||
|
);
|
||||||
|
|
||||||
|
comment on column produit.potassium IS 'K⁺ en mg/L';
|
||||||
|
comment on column produit.calcium IS 'Ca²⁺ en mg/L';
|
||||||
|
comment on column produit.magnesium IS 'Mg²⁺ en mg/L';
|
||||||
|
comment on column produit.sodium IS 'Na⁺ en mg/L';
|
||||||
|
comment on column produit.chlorure IS 'Cl⁻ en mg/L';
|
||||||
|
comment on column produit.sulfate IS 'SO₄²⁻ en mg/L';
|
||||||
|
comment on column produit.nitrate IS 'NO₃⁻ en mg/L';
|
||||||
|
comment on column produit.hydrogenocarbonate IS 'HCO₃⁻ en mg/L';
|
||||||
|
comment on column produit.silice IS s'SiO₂ en mg/L';
|
||||||
|
comment on column produit.fluor IS 'F en mg/L';
|
||||||
|
|
||||||
|
\COPY produit FROM '/tmp/produit.csv' (FORMAT CSV, header, ENCODING 'UTF8');
|
||||||
27
vector.sql
27
vector.sql
@@ -31,3 +31,30 @@ add column nutrition vector(10);
|
|||||||
|
|
||||||
UPDATE produits
|
UPDATE produits
|
||||||
SET nutrition = ARRAY[energie, proteines, glucide, sucre, graisse, graisse_saturee, sel, fibres, nutriscore, additifs]::vector;
|
SET nutrition = ARRAY[energie, proteines, glucide, sucre, graisse, graisse_saturee, sel, fibres, nutriscore, additifs]::vector;
|
||||||
|
|
||||||
|
|
||||||
|
with selection as (
|
||||||
|
select op.id, product_name, brands, "energy-kcal_100g", fat_100g, "saturated-fat_100g",
|
||||||
|
"carbohydrates_100g", "sugars_100g", "proteins_100g", "salt_100g", "fiber_100g",
|
||||||
|
"nutriscore_score", "additives_n", string_to_array(additives_en, ','),
|
||||||
|
"potassium_100g", "calcium_100g", "vitamin-a_100g", "vitamin-c_100g",
|
||||||
|
main_category_en
|
||||||
|
from openfoodfacts_cleaned op
|
||||||
|
left join produit p on p.id = op.id
|
||||||
|
where brands like 'Familia%'
|
||||||
|
and p.id is null
|
||||||
|
and "energy-kcal_100g" is not null
|
||||||
|
and proteins_100g is not null
|
||||||
|
and fat_100g is not null
|
||||||
|
and "saturated-fat_100g" is not null
|
||||||
|
and carbohydrates_100g is not null
|
||||||
|
and sugars_100g is not null
|
||||||
|
and salt_100g is not null
|
||||||
|
and nutriscore_score is not null
|
||||||
|
)
|
||||||
|
insert into produit (id, nom, marque,
|
||||||
|
energie, graisse, graisse_saturee,
|
||||||
|
glucide, sucre, proteines, sel,
|
||||||
|
fibres, nutriscore, additifs, additifs_list,
|
||||||
|
potassium, calcium, vitamin_a, vitamin_c, categorie)
|
||||||
|
select * from selection;
|
||||||
|
|||||||
Reference in New Issue
Block a user