R/fetch_fm_ids.R

Defines functions fetch_fm_ids

Documented in fetch_fm_ids

#' Fetch Fall Membership Ids
#'
#' #' @description
#' `r lifecycle::badge("deprecated")`
#'
#' This function was deprecated with the addition of the more generalized \code{\link{fetch_src_ids}} function
#'
#' @param year year to get fall membership for
#' @param include_pk logical. include pk students in the query?
#'
#' @return
#' @export
#'
#' @examples \dontrun{
#' fetch_fm_ids(2019)
#' }
fetch_fm_ids <- function(year, include_pk = TRUE) {

  #check that year is numeric
  yr <- check_year_type(year)

  #check that year is greater than or equal to 2014
  check_src_year(year)

  con <- set_con()

  base_qry <- paste0(' SELECT StudentId
                FROM [CCPS_Shared].[CCPS_Shared].[SRC_', yr, '_Fall]
                  WHERE ActiveStat = \'A\'
                  AND (ServDiv = 021
                    OR Tuition in (\'3\', \'7\')
                  )
                  AND FTE in (\'\')
                  ')

  qry <- if (include_pk == FALSE) {
    paste0(base_qry, "AND GradeLevel != \'PK\'")
  } else base_qry

  tmp <- odbc::dbGetQuery(con, qry)

  purrr::simplify(tmp)
}
ekholme-ccps/ccpsr documentation built on Aug. 17, 2021, 10:01 p.m.