From 4d1aae71bb55a10b9d28f65b8954bac3cbfa22d3 Mon Sep 17 00:00:00 2001
From: cedricbriandgithub <cedric.briand@eptb-vilaine.fr>
Date: Tue, 18 Oct 2022 15:11:09 +0200
Subject: [PATCH 1/2] Fixed problem with error not showing when logging as the
 wrong user references #22

---
 .dbeaver/.gitignore |  1 +
 R/stacomi.R         | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/.dbeaver/.gitignore b/.dbeaver/.gitignore
index b2c008c..8c508fa 100644
--- a/.dbeaver/.gitignore
+++ b/.dbeaver/.gitignore
@@ -4,3 +4,4 @@
 /data-sources.json
 /.project-metadata.json.bak
 /project-metadata.json
+/project-settings.json
diff --git a/R/stacomi.R b/R/stacomi.R
index 4fa5d02..3a03e69 100644
--- a/R/stacomi.R
+++ b/R/stacomi.R
@@ -28,13 +28,13 @@ load_stacomi <- function(...) {
 				password <- readline(prompt="Enter password: ")	
 				options("stacomiR.password"=password)
 			} else {
-				user <- "postgres"
-				password <- "postgres"
+				user <- "group_stacomi"
+				password <- "group_stacomi"
 				warning('no user set by default, reverted to user <- "postgres" and  password <- "postgres", 
-                you can change it with options("stacomiR.user"=user) and options("stacomiR.password"=password)')
+								you can change it with options("stacomiR.user"=user) and options("stacomiR.password"=password)')
 			}
 		}
-
+		
 		
 		con = new("ConnectionDB")
 		e = expression(con <- connect(con))
@@ -54,7 +54,9 @@ load_stacomi <- function(...) {
 		if (test) {
 			requete = new("RequeteDB")
 			requete@sql = paste0("select count(*) from ", sch, "t_lot_lot")
+			message <- NULL
 			requete <- stacomirtools::query(requete)
+			if (grepl("Error",requete@status)) stop(requete@status)			
 			if (nrow(requete@query) == 0) {
 				# the database link is not working or the 
 				# schema
-- 
GitLab


From 174785c13ea134b5b4a2f4998bd1ae214ceafef7 Mon Sep 17 00:00:00 2001
From: cedricbriandgithub <cedric.briand@eptb-vilaine.fr>
Date: Tue, 18 Oct 2022 15:50:58 +0200
Subject: [PATCH 2/2] fix: Added error message when problems with the db,
 usefull for shiny

---
 R/ref_dc.R        | 1 +
 R/report_annual.R | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/R/ref_dc.R b/R/ref_dc.R
index e9058ca..77cb6e6 100644
--- a/R/ref_dc.R
+++ b/R/ref_dc.R
@@ -105,6 +105,7 @@ setMethod(
             sep = ""
         )
         requete <- stacomirtools::query(requete)
+				if (grepl("Error",requete@status)) stop(requete@status)	
         # funout(gettext('The query to load counting devices is done
         # \n',domain='R-stacomiR'))
         object@data <- requete@query
diff --git a/R/report_annual.R b/R/report_annual.R
index 6446f8c..6de95c2 100644
--- a/R/report_annual.R
+++ b/R/report_annual.R
@@ -549,7 +549,7 @@ setMethod(
 						legend.text = dat0$ope_dic_identifiant
 						barplot(mat, legend.text = legend.text, ...)
 					} else {
-						barplot(mat, ...)
+						barplot(mat, legend.text=legend.text)
 					}
 					
 				} else if (length(lestax) == 1 & length(lesdic) == 1) {
-- 
GitLab