Skip to content

Commit

Permalink
Switched to one call for channel instead of two
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Lucey committed Nov 21, 2023
1 parent 526ffd2 commit c99f10f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions R/get_comland_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#'@export


get_comland_data <- function(channelSole, channelNova, filterByYear = NA,
get_comland_data <- function(channel, filterByYear = NA,
filterByArea = NA, useLanded = T, removeParts = T,
useHerringMaine = T, useForeign = T, refYear = NA,
refMonth = NA, disagSkatesHakes = T, aggArea = F,
Expand All @@ -51,13 +51,13 @@ get_comland_data <- function(channelSole, channelNova, filterByYear = NA,
call <- dbutils::capture_function_call()

#Pull raw data
comland <- comlandr::get_comland_raw_data(channelSole, channelNova,
comland <- comlandr::get_comland_raw_data(channel,
filterByYear, filterByArea,
useLanded, removeParts)

#Pull herring data from the state of Maine
if(useHerringMaine){
comland <- comlandr::get_herring_data(channelSole, comland,
comland <- comlandr::get_herring_data(channel, comland,
filterByYear, filterByArea,
useForeign)
}
Expand All @@ -66,7 +66,7 @@ get_comland_data <- function(channelSole, channelNova, filterByYear = NA,
if(useForeign){
#Look up NAFO divisions that contain Stat areas
if (all(!is.na(filterByArea))) {
NAFOAreas <- comlandr::get_areas(channelSole)$data %>%
NAFOAreas <- comlandr::get_areas(channel)$data %>%
dplyr::select(AREA,NAFDVCD) %>%
dplyr::filter(AREA %in% filterByArea) %>%
dplyr::pull(NAFDVCD) %>%
Expand All @@ -77,7 +77,7 @@ get_comland_data <- function(channelSole, channelNova, filterByYear = NA,

#Pull data and process to look like comland data
comland.foreign <- comlandr::get_foreign_data(filterByYear, filterByArea)
comland.foreign <- comlandr::process_foreign_data(channelSole, comland.foreign,
comland.foreign <- comlandr::process_foreign_data(channel, comland.foreign,
useHerringMaine)

#Combine foreign landings
Expand All @@ -91,13 +91,13 @@ get_comland_data <- function(channelSole, channelNova, filterByYear = NA,

#Disaggregate skates and hakes
if(disagSkatesHakes) comland <- comlandr::disaggregate_skates_hakes(comland,
channelSole,
channel,
filterByYear, filterByArea)

#Aggregate areas
if(aggArea) comland <- comlandr::aggregate_area(comland, userAreas,
areaDescription, propDescription,
useForeign, channelSole,
useForeign, channel,
applyPropLand, applyPropValue)

#Aggregate gears
Expand Down
6 changes: 3 additions & 3 deletions R/get_comland_raw_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#'
#'@export

get_comland_raw_data <- function(channelSole, channelNova, filterByYear = NA,
filterByArea = NA, useLanded = T, removeParts = T){
get_comland_raw_data <- function(channel, filterByYear = NA, filterByArea = NA,
useLanded = T, removeParts = T){

#If not specifying a year default to 1964 - 2019
if(is.na(filterByYear[1])) filterByYear <- 1964:2019
Expand Down Expand Up @@ -107,7 +107,7 @@ get_comland_raw_data <- function(channelSole, channelNova, filterByYear = NA,
where year in (", filteryears, ")
group by year, month, negear, toncl2, nespp3, nespp4, area,
utilcd, mesh, market_code")
comland <- data.table::as.data.table(DBI::dbGetQuery(channelSole, landings.qry))
comland <- data.table::as.data.table(DBI::dbGetQuery(channel, landings.qry))

sql <- landings.qry

Expand Down

0 comments on commit c99f10f

Please sign in to comment.