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

oceano app: "no observations were found"; + log all queries w/ response stats; + Shiny bookmark query state #24

Open
1 of 2 tasks
bbest opened this issue Nov 29, 2023 · 7 comments

Comments

@bbest
Copy link
Contributor

bbest commented Nov 29, 2023

from @evsatt:

I have been wanting to share Oceano's app with some of the folks I have been meeting about regarding utility for long term patterns related to Offshore Wind (e.g., showing a trend over time for temperature). But I can't easily get the CalCOFI data to load - it says "sorry no obs found". Am I doing something wrong?

image

This points to the very real need to:

  • + Query Log
    Log all queries and basic stats on the response, but particularly for those queries which fail and need to be debugged.
  • + Link to Shiny bookmark
    Also add a copy link button to return to the app to the same state (possible with Shiny Bookmarking).
@bbest
Copy link
Contributor Author

bbest commented Nov 29, 2023

Hi @evsatt ,

Sorry about the issue here, which I'm having trouble understanding and replicating. I see a contoured surface map, so not sure if it was for a different area or other setting not visible when you clicked Update. This points to the very real need to log all queries and basic stats on the response, but particularly for those queries which fail and need to be debugged. And ideally to also add a copy link button to return to the app in the same state (possible with Shiny Bookmarking).

Here's what I was able to successfully generate:

Screenshot 2023-11-29 at 10 51 27 AM

And some of the outputs from the bottom Downloads links:

oceano-app_query-5800caf2.zip

@evsatt
Copy link

evsatt commented Nov 29, 2023 via email

@bbest bbest changed the title oceano app: "no observations were found"; + logging of queries and response stats oceano app: "no observations were found"; + log all queries w/ response stats; + Shiny bookmark query state Nov 29, 2023
@bbest
Copy link
Contributor Author

bbest commented Nov 29, 2023

Yes please! I'll try to have this sorted by our meeting Wednesday

@evsatt
Copy link

evsatt commented Nov 29, 2023 via email

bbest added a commit that referenced this issue Dec 6, 2023
+ Shiny bookmark query state #24
@bbest
Copy link
Contributor Author

bbest commented Dec 6, 2023

Shiny Bookmarking in URL

Now the URL in the browser's location bar gets updated as the user changes input values, so the URL can be shared to return to the same state.

References:

Here are the URLs for two maps with entirely different inputs:

  1. initial
    URL decoded: https://shiny.calcofi.io/oceano/?_inputs_&

    • aoi_cat="CalCOFI Zones"&
    • aoi_ewkt=null&
    • aoi_keys=["cc_nearshore-extended","cc_offshore-extended","cc_nearshore-standard","cc_offshore-standard"]&
    • aoi_rows=[1,2,5,6]&
    • hash="ffefc04c"&
    • map_center={"lng":-122.080078125,"lat":33.9068955512887}&
    • map_init=true&
    • map_zoom=6&
    • mapedit_counter=1&
    • num_depth_bins=10&
    • sel_date_range=["2015-01-25","2020-01-26"]&
    • sel_depth_range=[0,515]&
    • sel_qtr=["1","2"]&
    • sel_time_step="year"&
    • sel_val="avg"&
    • sel_var="ctd_bottles.t_degc"&
    • tabs="map"
    image
  2. modified
    URL decoded: https://shiny.calcofi.io/oceano/?_inputs_&

    • aoi_cat="CalCOFI Zones"
    • aoi_keys=null&
    • aoi_ewkt="SRID=4326;POLYGON ((-122.239895 34.052659, -120.120392 32.915188, -120.952606 34.803091, -122.239895 34.052659))"&
    • aoi_rows=null&
    • hash="0885655b"&
    • map_zoom=7&
    • map_center={"lng":-121.1801435,"lat":33.8643573446832}&
    • num_depth_bins=10&
    • sel_date_range=["2010-01-01","2019-01-01"]&
    • sel_depth_range=[120,1000]&
    • sel_place_category="CalCOFI Zones"&
    • sel_qtr=["3","4"]&
    • sel_time_step="year"&
    • sel_val="avg"&
    • sel_var="ctd_bottles.salinity"&
    • tabs="map"&
    • map_init=true&
    • mapedit_counter=2&
    image

@bbest
Copy link
Contributor Author

bbest commented Dec 6, 2023

Logging with logger or loggit

Not sure logging is necessary now with bookmarkable URL, but # comments for logger and loggit included.

apps/oceano/global.R

Lines 8 to 18 in 560187f

# logger, loggit,
lubridate, plotly, png, readr, shiny, shinydashboard, shinyjs,
stringr, webshot)
# remotes::install_github("calcofi/calcofi4r", force=T) # install remote
# devtools::install_local(here::here("../calcofi4r"), force=T) # install local
# devtools::load_all(here("../calcofi4r")) # debug
# loggit::set_logfile("/share/github/apps_dev/oceano/logs/loggit.log")
# loggit::read_logs()
# logger::log_appender(appender_file("/share/github/apps_dev/oceano/logs/logger.log"))
# logger::log_appender()

apps/libs/functions.R

Lines 339 to 363 in 560187f

# log_info(
# list(get_map_data = list(
# variable = variable,
# value = value,
# aoi_ewkt = aoi_ewkt,
# aoi_keys = aoi_keys)))
# loggit(
# "INFO",
# "get_map_data()",
# data_json = jsonlite::toJSON(list(
# variable = variable,
# value = value,
# aoi_ewkt = aoi_ewkt,
# aoi_keys = aoi_keys,
# date_beg = date_beg,
# date_end = date_end,
# date_qrtr = date_qrtr,
# depth_m_min = depth_m_min,
# depth_m_max = depth_m_max,
# n_bins = n_bins,
# return_type = return_type,
# dir_cache = dir_cache,
# clientData = clientData)) |>
# as.character())

Skipping shinylogs since logging excessive and not customizable.

Surprisingly the client's IP address is not included in Shiny's session$clientData so can't easily include in log:

@bbest bbest added this to Management Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants