From d3baa2bedc0d029f341efc430a5a34e5d3a16672 Mon Sep 17 00:00:00 2001 From: "mael.pretet" Date: Mon, 31 Mar 2025 15:15:11 +0200 Subject: [PATCH 1/2] =?UTF-8?q?rename:=20changement=20du=20nom=20du=20r?= =?UTF-8?q?=C3=A9pertoire=20SQL=20en=20sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fonctions/create_df_opj.R | 2 +- {SQL => sql}/export_a_plat_OPJ.sql | 0 sql/export_a_plat_OPJ_old.sql | 82 ++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) rename {SQL => sql}/export_a_plat_OPJ.sql (100%) create mode 100644 sql/export_a_plat_OPJ_old.sql diff --git a/fonctions/create_df_opj.R b/fonctions/create_df_opj.R index 74526fd..f0da895 100644 --- a/fonctions/create_df_opj.R +++ b/fonctions/create_df_opj.R @@ -42,7 +42,7 @@ if ((!file.exists("data/rdata/df_opj.rds") | # Sys.Date()-as.Date(file.info("data/rdata/df_opj.rds")$ctime) > 5)) & is_intranet()) { # que le fichier a plus de 5 jours] # Lecture depuis la base mosaic - df_opj = import_from_mosaic(query = read_sql_query("SQL/export_a_plat_OPJ.sql"), + df_opj = import_from_mosaic(query = read_sql_query("sql/export_a_plat_OPJ.sql"), database_name = "spgp") # On sauvegarde si on ne se trouve pas sur le serveur gitlab diff --git a/SQL/export_a_plat_OPJ.sql b/sql/export_a_plat_OPJ.sql similarity index 100% rename from SQL/export_a_plat_OPJ.sql rename to sql/export_a_plat_OPJ.sql diff --git a/sql/export_a_plat_OPJ_old.sql b/sql/export_a_plat_OPJ_old.sql new file mode 100644 index 0000000..0f11e46 --- /dev/null +++ b/sql/export_a_plat_OPJ_old.sql @@ -0,0 +1,82 @@ +SELECT + pp.id as participation_id, + pp.startDate as date_collection, + year(pp.startDate) as annee, + po.nbTaxons as abondance, + st_x(soa.geopoint) as longitude, + st_y(soa.geopoint) as latitude, + soa.deptCode as dept_code, + soa.postalCode as code_postal, + soa.userId as user_id, + usr.email as email, + soay.observationAreaId as jardin_id, + t.value as num_semaine, + t2.value as nom_espece, + t3.value as freq_passage, + t4.value as type_environnement, + t5.value as surface, + t6.value as distance_bois, + t7.value as distance_champs, + t8.value as distance_prairie, + t9.value as type_Engrais, + t10.value as type_Insecticide, + t11.value as type_Herbicide, + t12.value as type_Fongicide, + t13.value as type_AntiLimace, + t14.value as type_BouillieBordelaise, + t15.value as frequence_Engrais, + t16.value as frequence_Insecticide, + t17.value as frequence_Herbicide, + t18.value as frequence_Fongicide, + t19.value as frequence_AntiLimace, + t20.value as frequence_BouillieBordelaise +FROM + spgp.pj_observation po +LEFT JOIN spgp.pj_participation pp on + pp.id = po.participationId +LEFT JOIN spgp.spj_observation_area_year soay on + pp.observationAreaYearId = soay.id +LEFT JOIN spgp.spj_observation_area soa on + soay.observationAreaId = soa.id +LEFT JOIN spgp.users usr on + soa.userId = usr.id +LEFT JOIN thesaurus t on + pp.weekId = t.id +LEFT JOIN thesaurus t2 on + po.taxonId = t2.id +LEFT JOIN thesaurus t3 on + pp.frequencePassageId = t3.id +LEFT JOIN thesaurus t4 on + soay.environmentId = t4.id +LEFT JOIN thesaurus t5 on + soay.surfaceId = t5.id +LEFT JOIN thesaurus t6 on + soay.distanceBoisId = t6.id +LEFT JOIN thesaurus t7 on + soay.distanceChampId = t7.id +LEFT JOIN thesaurus t8 on + soay.distancePrairieId = t8.id +LEFT JOIN thesaurus t9 on + soay.typeEngraisId = t9.id +LEFT JOIN thesaurus t10 on + soay.typeInsecticideId = t10.id +LEFT JOIN thesaurus t11 on + soay.typeHerbicideId = t11.id +LEFT JOIN thesaurus t12 on + soay.typeFongicideId = t12.id +LEFT JOIN thesaurus t13 on + soay.typeAntiLimaceId = t13.id +LEFT JOIN thesaurus t14 on + soay.typeBouillieBordelaiseId = t14.id +LEFT JOIN thesaurus t15 on + soay.frequenceEngraisId = t15.id +LEFT JOIN thesaurus t16 on + soay.frequenceInsecticideId = t16.id +LEFT JOIN thesaurus t17 on + soay.frequenceHerbicideId = t17.id +LEFT JOIN thesaurus t18 on + soay.frequenceFongicideId = t18.id +LEFT JOIN thesaurus t19 on + soay.frequenceAntiLimaceId = t19.id +LEFT JOIN thesaurus t20 on + soay.frequenceBouillieBordelaiseId = t20.id \ No newline at end of file -- GitLab From fcf94f94aee9f441b2d1c68c7db65940f86eae9f Mon Sep 17 00:00:00 2001 From: "mael.pretet" Date: Mon, 7 Apr 2025 11:27:00 +0200 Subject: [PATCH 2/2] doc: ajout partie fonctions au readme --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65f083f..3f9365e 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,27 @@ - maquette_espece.qmd : Fichier quarto permettant de générer les restitutions liées à l'opération papillons des jardins -## Fonctions -Fonctions pour générer les dataframe et les fonctions graphiques \ No newline at end of file +## carte + +## data + +## fonctions +Fonctions pour générer les dataframe et les fonctions graphiques +- carte +- create_df_old +- create_df_one_sp +- create_df_opj +- function_graphics +- function_import_from_mosaic +- library +- var + +## out +Dossier de stockages des sorties html générées à partir des quarto (notamment avec le script programs/boucle_quarto.R) + +## programs +- boucle_quarto +- generate_html + +## sql +Requête sql pour obtenir un export à plat de la base de données opération papillon des jardins \ No newline at end of file -- GitLab