NewGraphEnvironment / fpr

Fish Passage Reporting functions for British Columbia
http://www.newgraphenvironment.com/fpr/
Other
2 stars 2 forks source link

`fpr_photo_qa` not catching certain duplicates #61

Open lucy-schick opened 8 months ago

lucy-schick commented 8 months ago

fpr_photo_qa is not catching certain duplicates. See example below with _inlet copy photo

image

Usually we do not want there to be:

  1. spaces in file names
  2. duplicates of reserved names for PSCIS required photos (ex. *_inlet.JPG and *inlet2.JPG are fine to submit but *inlet.JPG and *inlet copy.JPG may not be.

fpr_photo_qa_df is not catching this duplicate because it looks like fpr_photo_qa is not returning a list when it should be since there are 2 inlet photos (see screenshot).

I think this is happening because this line in fpr_photo_qa

stringr::str_subset(., '_barrel\\.|_outlet\\.|_upstream\\.|_downstream\\.|_road\\.|_inlet\\.') %>%

is only returning photos that contain the _reserved name ending with a . (example _intlet.) and since the copy photo is_inlet copy it doesn't grab it and therefore won't return a list.

Just tried removing \\. so that it returns photos with any ending and it does include the copy photo but got some other errors.

stringr::str_subset(., '_barrel |_outlet |_upstream |_downstream |_road |_inlet') %>%

Screen Shot 2024-02-29 at 2 15 06 PM

NewGraphEnvironment commented 2 weeks ago

fpr_photo_qa2 is an updated fpr_photo_qa that should catch all duplicate photos

here are some examples of how to use without the help of fpr_photo_qa_df which still relies on fpr_photo_qa

qa_all <- fpr::fpr_photo_qa2(
  dat = form_both,
  dir_photos = dir_photos
) %>%
  data.table::rbindlist(fill = TRUE)

# here is the test for missing individual photos
fpr::fpr_photo_qa2(
  dat = form_both,
  dir_photos = dir_photos
) |>
  bind_rows() |>
  dplyr::filter(if_any(everything(), is.na))
NewGraphEnvironment commented 1 week ago

these examples need to be added to the docs and now that we have confirmation that duplicates are actually an ishy we can swap fpr_photo_qa2 changes into fpr_photo_qa. Legacy string search for reserved photos (ex. _barrel\\. will come in handy for a future renaming function that can rename the offending photos when they are not our target reserved photo submission.