77# and geographic area mismatches.
88# Updates: Grouped skate complex, removed foreign landings, isolated overages,
99# dynamically converted complex units (e.g., 'Thousand lbs'),
10- # capped visual outliers, and hardcoded BSB stock exception.
10+ # capped visual outliers, hardcoded BSB stock exception,
11+ # and added dynamic username prompt.
1112# =========================================================================
1213
1314# 1. Setup & Load Libraries -----------------------------------------------
@@ -18,6 +19,14 @@ library(data.table)
1819library(dbutils )
1920library(DBI )
2021
22+ # Prompt for database username
23+ if (interactive()) {
24+ db_username <- readline(prompt = " Enter your NEFSC database username: " )
25+ if (trimws(db_username ) == " " ) stop(" Username cannot be blank." )
26+ } else {
27+ stop(" This script must be run interactively to enter a database username." )
28+ }
29+
2130start_year <- 1985
2231end_year <- as.integer(format(Sys.Date(), " %Y" )) - 1
2332
@@ -33,7 +42,7 @@ if (!dir.exists("data-raw")) {
3342}
3443
3544# 2. Pull Data from NEFSC Database ----------------------------------------
36- channel <- dbutils :: connect_to_database(" NEFSC_pw_oraprod" , " MGREZLIK " )
45+ channel <- dbutils :: connect_to_database(" NEFSC_pw_oraprod" , db_username )
3746
3847# Create a master area map covering all possible US statistical areas (1 to 999)
3948coastwide <- data.table(AREA = 1 : 999 , EPU = " Coastwide" )
@@ -227,7 +236,7 @@ chunk_size <- 6
227236
228237for (i in seq(1 , length(species_list ), by = chunk_size )) {
229238 target_spp <- species_list [i : min((i + chunk_size - 1 ), length(species_list ))]
230-
239+
231240 p <- hypothesis_df | >
232241 filter(Species %in% target_spp ) | >
233242 group_by(Species ) | >
@@ -263,7 +272,7 @@ for (i in seq(1, length(species_list), by = chunk_size)) {
263272 color = " Data Source"
264273 ) +
265274 theme(legend.position = " bottom" )
266-
275+
267276 print(p )
268277}
269278
0 commit comments