Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
^Meta$
^_pkgdown\.yml$
^pkgdown$
^.Renviron
^[.]?air[.]toml$
6 changes: 4 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
# Configuring ojodb access for github actions
OJO_DRIVER: ${{ secrets.OJO_DRIVER }}
OJO_DATABASE: ${{ secrets.OJO_DATABASE }}
OJO_HOST: ${{ secrets.OJO_HOST }}
OJO_PORT: ${{ secrets.OJO_PORT }}
OJO_DEFAULT_USER: ${{ secrets.OJO_DEFAULT_USER }}
OJO_DEFAULT_PASS: ${{ secrets.OJO_DEFAULT_PASS }}
OJO_USER: ${{ secrets.OJO_USER }}
OJO_PASS: ${{ secrets.OJO_PASS }}
OJO_SSL_MODE: ${{ secrets.OJO_SSL_MODE }}
# Encoded secrets
OJO_SSL_CERT_BASE64: ${{ secrets.OJO_SSL_CERT_BASE64 }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
# Configuring ojodb access for github actions
OJO_DRIVER: ${{ secrets.OJO_DRIVER }}
OJO_DATABASE: ${{ secrets.OJO_DATABASE }}
OJO_HOST: ${{ secrets.OJO_HOST }}
OJO_PORT: ${{ secrets.OJO_PORT }}
OJO_DEFAULT_USER: ${{ secrets.OJO_DEFAULT_USER }}
OJO_DEFAULT_PASS: ${{ secrets.OJO_DEFAULT_PASS }}
OJO_USER: ${{ secrets.OJO_USER }}
OJO_PASS: ${{ secrets.OJO_PASS }}
OJO_SSL_MODE: ${{ secrets.OJO_SSL_MODE }}
# Encoded secrets
OJO_SSL_CERT_BASE64: ${{ secrets.OJO_SSL_CERT_BASE64 }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# Configuring ojodb access for github actions
OJO_DRIVER: ${{ secrets.OJO_DRIVER }}
OJO_DATABASE: ${{ secrets.OJO_DATABASE }}
OJO_HOST: ${{ secrets.OJO_HOST }}
OJO_PORT: ${{ secrets.OJO_PORT }}
OJO_DEFAULT_USER: ${{ secrets.OJO_DEFAULT_USER }}
OJO_DEFAULT_PASS: ${{ secrets.OJO_DEFAULT_PASS }}
OJO_USER: ${{ secrets.OJO_USER }}
OJO_PASS: ${{ secrets.OJO_PASS }}
OJO_SSL_MODE: ${{ secrets.OJO_SSL_MODE }}
# Encoded secrets
OJO_SSL_CERT_BASE64: ${{ secrets.OJO_SSL_CERT_BASE64 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ inst/doc
/doc/
/Meta/
docs
.Renviron
40 changes: 21 additions & 19 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ojodb
Title: Analyze Data from the Open Justice Oklahoma Database
Version: 2.11.1
Version: 3.0.0
Authors@R: c(
person(
given = "Brancen",
Expand Down Expand Up @@ -33,23 +33,23 @@ Authors@R: c(
))
Description: {ojodb} provides convenient functions to query court data from the Open Justice Oklahoma database.
Imports:
cli,
dbplyr,
DBI,
ggplot2,
glue,
lifecycle,
lubridate,
pool,
purrr,
rlang,
RPostgres,
stringi,
stringr,
tibble,
tidyr,
utils,
withr
cli,
dbplyr,
DBI,
digest,
glue,
lubridate,
pool,
purrr,
rlang,
RPostgres,
stringi,
stringr,
tibble,
tidyr,
utils,
withr,
yaml
Suggests:
arrow,
attachment,
Expand All @@ -64,17 +64,20 @@ Suggests:
janitor,
knitr,
languageserver,
lifecycle,
lintr,
readr,
roxygen2,
rmarkdown,
RSQLite,
rvest,
styler,
testthat (>= 3.0.0),
tidycensus,
usethis,
xml2
Depends:
R (>= 4.1.0),
dplyr
Remotes:
nx10/httpgd
Expand All @@ -84,7 +87,6 @@ LazyData: true
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/testthat/parallel: true
URL: https://github.com/openjusticeok/ojodb
BugReports: https://github.com/openjusticeok/ojodb/issues
Roxygen: list(markdown = TRUE)
11 changes: 3 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(db_config)
export(ojo_add_counts)
export(ojo_add_issues)
export(ojo_add_minutes)
Expand All @@ -9,31 +10,25 @@ export(ojo_case_types)
export(ojo_check_ssl)
export(ojo_civ_cases)
export(ojo_collect)
export(ojo_color)
export(ojo_connect)
export(ojo_connection_string)
export(ojo_county_population)
export(ojo_crim_cases)
export(ojo_env)
export(ojo_eviction_cases)
export(ojo_fill)
export(ojo_fiscal_year)
export(ojo_list_schemas)
export(ojo_list_tables)
export(ojo_list_vars)
export(ojo_pal)
export(ojo_pool)
export(ojo_query)
export(ojo_search_minutes)
export(ojo_show_row)
export(ojo_tbl)
export(ojo_theme)
export(ojo_version)
import(dplyr)
importFrom(dplyr,case_when)
importFrom(dplyr,filter)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(ggplot2,"%+replace%")
importFrom(lubridate,as_date)
importFrom(lubridate,floor_date)
importFrom(stringr,str_detect)
30 changes: 30 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# ojodb 3.0.0

## Breaking Changes
- **Connection Management:** `ojo_connect()` now requires a `db_config` object (or creates a default one) and returns a connection object directly, instead of using side effects to store it in a package environment. The arguments `.admin`, `.driver`, `.global`, `.env`, and `.pool` have been removed.
- **Authentication:** `ojo_auth()` now accepts a `db_config` object. The arguments `host`, `port`, `username`, `password`, `.admin`, and `.overwrite` (old signature) have been replaced/consolidated.
- **Environment Variables:**
- `OJO_ADMIN_USER` and `OJO_DEFAULT_USER` have been consolidated into `OJO_USER`.
- `OJO_ADMIN_PASS` and `OJO_DEFAULT_PASS` have been consolidated into `OJO_PASS`.
- `OJO_SSL_MODE` is no longer hardcoded to "verify-ca".
- `OJO_SSL_ROOT_CERT`, `OJO_SSL_CERT`, and `OJO_SSL_KEY` are now standard environment variables.
- Removed deprecated functions: `ojo_env()`, `ojo_show_row()`, and `ojo_search_minutes()`.
- Removed `tbl_from_gcs_arrow()`, `tbl_from_gcs_duckdb()`, and `tbl_from_rpostgres()`.
- Standardized naming conventions across the package.

## New Features
- **Flexible Configuration:** Added `db_config()` to create configuration objects from arguments, YAML files, or environment variables.
- **Connection Pooling:** Added `ojo_pool()` to easily create managed connection pools for applications (e.g., Shiny).
- **Explicit Connections:** Added `con` argument to all major query functions (`ojo_case_types()`, `ojo_civ_cases()`, `ojo_crim_cases()`, `ojo_eviction_cases()`, `ojo_tbl()`, `ojo_query()`, etc.) to allow passing specific connection objects.
- **Default Connection:** `ojo_default_connection()` now manages the interactive singleton connection, ensuring a smoother user experience for interactive sessions.
- Improved sorting in `ojo_list_tables()` and `ojo_list_schemas()`.

## Bug Fixes
- Fixed `ojo_check_ssl()` to correctly handle both single connections and connection pools.
- Fixed `ojo_add_party_details()` to properly handle lazy tibbles and provide better error messages.
- Fixed a bug in `ojo_collect()`'s result estimation.

## Package Maintenance
- Significant increase in test coverage, including tests for previously untested utility and query functions.
- Documentation updates and standardization.

# ojodb 2.11.1 (2025-07-01)

## Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.ojo_env <- rlang::new_environment()
.ojo_env <- rlang::new_environment()
21 changes: 21 additions & 0 deletions R/globals.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
utils::globalVariables(
c(
"NAME",
"case_id",
"case_type",
"column_name",
"court",
"date_filed",
"description",
"disposition",
"disposition_date",
"district",
"schema",
"schema_name",
"table_name",
"table_schema",
"value",
"variable",
"year"
)
)
12 changes: 7 additions & 5 deletions R/ojo_add_minutes.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
#' Query the Open Justice Oklahoma database for the minutes of a case
#'
#' @param data A lazy tibble containing the cases to query
#' @param con The OJO database connection to use
#' @param ... Placeholder for additional arguments
#'
#'
#' @export ojo_add_minutes
#' @returns A lazy tibble containing the resulting cases with minutes
#'
#'
#' @examples
#' \dontrun{
#' ojo_add_minutes()
#' }
#'
ojo_add_minutes <- function(data, ...) {
minutes <- ojo_tbl("minute")
ojo_add_minutes <- function(data, con = NULL, ...) {
minutes <- ojo_tbl("minute", con = con)

data <- data |>
dplyr::left_join(minutes,
dplyr::left_join(
minutes,
by = c("id" = "case_id"),
suffix = c("", ".minute")
)
Expand Down
19 changes: 11 additions & 8 deletions R/ojo_add_party_details.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @param data A lazy tibble containing the results of a parties query
#' @param vars A character vector of variables to return
#' @param con The OJO database connection to use
#' @param ... Placeholder for additional arguments
#'
#' @export ojo_add_party_details
Expand All @@ -13,7 +14,7 @@
#' ojo_add_party_details()
#' }
#'
ojo_add_party_details <- function(data, vars = NULL, ...) {
ojo_add_party_details <- function(data, vars = NULL, con = NULL, ...) {
if (!inherits(data, "tbl_lazy")) {
stop("Don't use `collect()` before this function")
}
Expand All @@ -22,17 +23,19 @@ ojo_add_party_details <- function(data, vars = NULL, ...) {

if (!"party" %in% columns) {
if ("parties" %in% columns) {
if (inherits(data$parties, "pq__text")) {
stop("You must first unnest the `parties` column")
} else {
stop("Make sure you unnested the `parties` column into a column named `party`")
}
stop(
"Data contains a `parties` column but no `party` column. ",
"You must first unnest the `parties` column into a column named `party`."
)
}
stop("Data must contain a column named `party`")
stop("Data must contain a column named `party`.")
}

data <- data |>
dplyr::left_join(ojo_tbl("person_record"), by = c("party" = "id"))
dplyr::left_join(
ojo_tbl("person_record", con = con),
by = c("party" = "id")
)

return(data)
}
Loading