-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
106 lines (90 loc) · 3.76 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Restore the renv environment, excluding shinyuieditor
# renv::restore(exclude = c("shinyuieditor"), prompt= FALSE)
# try(pool::dbDisconnect(pool))
# Source install script
before_package <-Sys.time()
print(before_package)
require(here)
# source(here::here('install.R'))
unique_packages <- c("xts","raster", "ggplot2",
"RPostgreSQL", "here", "tools", "sf", "dplyr", "qs",
"futile.logger", "shinyjs", "tidyr", "bslib",
"shiny", "readr", "glue", "stringr", "knitr",
"DT", "viridis", "leaflet", "geojsonsf", "scales",
"dotenv", "zoo", "RColorBrewer", "shinycssloaders", "data.table", "htmlwidgets",
"xml2", "gridlayout", "dygraphs", "plotly","leaflet.extras","leaflet.minicharts",
"pool", "jsonlite", "tmap"
)
require(futile.logger)
lapply(unique_packages, function(pkg) {
start_time <- Sys.time() # Record start time
flog.info("Loading package: %s", pkg)
library(pkg, character.only = TRUE)
end_time <- Sys.time() # Record end time
load_duration <- end_time - start_time # Calculate duration
flog.info("Loaded package: %s in %s seconds", pkg, load_duration)
})
# Log total loading time
flog.info("All libraries loaded successfully in %s seconds", Sys.time() - before_package)
# Log the loading of libraries
flog.info("All libraries loaded successfully.")
#create default_dataset
source(here::here("download_GTA_data.R"))
source(here::here("create_or_load_default_dataset.R"))
source(here::here("modules/load_ui_modules.R"))
source(here::here("modules/db_connect.R"))
load_ui_modules()
flog.info("Sourced loading ui modules dataset")
variable <- c("source_authority",
"fishing_fleet",
"species_group",
"Gear",
"gear_type",
"species_name",
"fishing_mode",
"measurement_unit",
"gridtype",
"issue",
# "measurement",
# "measurement_type",
"species"
)
flog.info(sprintf("Variables: %s", paste0(variable)))
# Load functions from external sources
source("https://raw.githubusercontent.com/juldebar/IRDTunaAtlas/master/R/TunaAtlas_i6_SpeciesMap.R")
source("https://raw.githubusercontent.com/juldebar/IRDTunaAtlas/master/R/TunaAtlas_i11_CatchesByCountry.R")
flog.info("Functions loaded")
getTarget <- function(category) {
target <- targettes[[category]]
return(target)
}
# Adding resource path to display html -------------------------------------
# addResourcePath("www", here::here("www"))
sql_query_init <- readRDS(here::here("tab_panels/sql_query_init.rds"))
flog.info("SQl query loaded")
# map_init <- read_html(here::here("www/map_init.html"))
flog.info("Map init loaded")
# Générer les options d'analyse
# source(here::here("tab_panels/sidebar_ui_with_variable_to_display.R"))
source(here::here("tab_panels/sidebar_ui.R"))
# Générer targetVariables et targettes
# if(exists("debug_mode") && debug_mode){
# default_dataset_preloaded <- readRDS(here::here("data/default_dataset_preloaded.rds"))
# } else {
# default_dataset_preloaded <- readRDS(here::here("data/datasf.rds"))
# }
source(here::here("modules/initialize_reactive_values.R"))
source(here::here("R/palette_settings.R"))
source(here::here("global/generate_dimensions_palettes.R"))
source(here::here("R/get_html_title.R"))
source(here::here("R/load_data.R"))
source(here::here("R/getPalette.R")) # do not knwo why we should run it as it is supposed to be ran after global.R but yet it is not
addResourcePath("www", here::here("www"))
more_about = function(){
generateRmdNavMenu("rmd_docs", nav_bar_menu_html)
}
outputmoreabout <- more_about()
# Rprofmem("memory_profile.txt")
# Rprofmem(NULL)
# Log that the UI and server files have been sourced successfully
flog.info(paste0("Global.R file loaded in ", Sys.time() - before_package, " seconds"))