Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior when collecting #149

Closed
brancengregory opened this issue Apr 28, 2023 · 1 comment
Closed

Unexpected behavior when collecting #149

brancengregory opened this issue Apr 28, 2023 · 1 comment

Comments

@brancengregory
Copy link
Member

Just ran this script:

library(ojoverse)
library(lubridate)

march_entries <- ojo_tbl("process_log", schema = "eviction_addresses") |>
  filter(
    updated_at >= "2023-03-01",
    updated_at < "2023-04-01"
  ) |>
  mutate(
    date_entered = floor_date(created_at, "day") |>
      as_date(),
  ) |>
  select(
    case,
    date_entered
  )

march_entries |>
  left_join(
    ojo_tbl("case"),
    by = c("case" = "id")
  ) |>
  left_join(
    ojo_tbl("issue"),
    by = c("case" = "case_id")
  ) |>
  select(
    case,
    date_filed,
    date_entered,
    disposition_date,
    disposition
  ) |>
  mutate(
    clean_disposition = case_when(
      str_detect(disposition,  "DISMISS") ~ "DISMISSED",
      str_detect(disposition,  "JUDGMENT|JUDGEMENT") ~
        case_when(
          str_detect(disposition,  "DEFAULT") ~ "DEFAULT JUDGMENT",
          str_detect(disposition,  "PLAINTIFF") ~ "JUDGMENT FOR PLAINTIFF",
          str_detect(disposition,  "DEFENDANT") ~ "JUDGMENT FOR DEFENDANT",
          TRUE ~ "JUDGMENT ENTERED"
        ),
      str_detect(disposition,  "ADVISEMENT") ~ "UNDER ADVISEMENT",
      TRUE ~ NA_character_
    )
  ) |>
  mutate(
    judgment = case_when(
      clean_disposition %in% c("DEFAULT JUDGMENT", "JUDGMENT FOR PLAINTIFF") ~ "Landlord",
      clean_disposition == "JUDGMENT FOR DEFENDANT" ~ "Tenant",
      clean_disposition == "JUDGMENT ENTERED" ~ "Decided, Outcome Unknown",
      clean_disposition == "DISMISSED" ~ "Dismissed (Settled Outside Court)",
      !is.na(clean_disposition) ~ "Other",
      TRUE ~ NA_character_
    )
  ) |>
  count(disposition, clean_disposition, judgment)

Recieved this output:

── Connection: [bgregory@34.122.10.67:5432/ojodb] ─────────────────────────────────────────────── ojodb 2.5.0 ──
Error in `rlang::warn()`:for matching results...
! `.frequency_id` must be supplied with `.frequency`.
Run `rlang::last_error()` to see where the error occurred.Something went wrong sending your query to the database! Please check your connection. [35ms]
@andrewjbe
Copy link
Collaborator

andrewjbe commented Aug 29, 2023

I believe this was resolved by #152 -- the example code runs successfully now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants