Skip to content

Conversation

nmdefries
Copy link
Collaborator

  • Set initial as-of date for hospitalizations to avoid as of-finding loop/replot.
  • Factor out lists of allowed tabs x target variables for brevity. Use tab name to index into list to avoid plotting when selected target variable shouldn't be displayed on that tab (i.e. first attempted plot when user switches tabs).
  • Resolve issue where first "current" tab instance doesn't correctly show as-of truth data due to ifelse coercing dates into numerics; use dplyr::if_else instead.

@nmdefries nmdefries requested a review from krivard April 12, 2023 21:53
Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this project is steadily becoming actual software instead of a bunch of bodges in a trenchcoat and i love it.

great work! can merge as-is, questions minor

app/server.R Outdated
@@ -131,14 +131,14 @@ server <- function(input, output, session) {
HOSP_CURRENT <- resolveCurrentHospDay()

PREV_AS_OF_DATA <- reactiveVal(NULL)
AS_OF_CHOICES <- reactiveVal(NULL)
AS_OF_CHOICES <- reactiveVal(resolveCurrentHospDay())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we need to run resolveCurrentHospDay again, or can we use the recently-computed value from HOSP_CURRENT?

is the advantage of computing this as a reactive value that if a user leaves the dash open for long periods of time, they'll automatically see updates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me that the main goal of AS_OF_CHOICES being reactive is to be easy to update from child processes. It doesn't look like its reactive behavior will ever be triggered since as of choices will only change when the target variable changes, which causes the same replotting and recalculating that AS_OF_CHOICES would.

I think we're safe to make it into a global instead, but then we'll need to do out-of-environment assignment (<<-). Knowing that, do you have a preference one way or the other?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm I don't feel strongly about it -- a global vs some superfluous reactivity are probably equally annoying. that suggests, do whatever's easy :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we should do a bigger refactor of the reactive behavior, I'm leaving this as-is and will create an issue.

The UI defines startup selection values globally, for all users
assigned to that Shiny session. Startup values are treated as constants,
so a hard-coded asof date won't update if the Shiny session persists (is
continually used) across a date boundary that would normally change the
default asof selection. Thus, we need to set the starting asof value on
a user-by-user basis so that it is recalculated when a new dashboard
instance is opened. To do that, set the initial asof value back to empty
("") and run an updater observe on dashboard startup only.

In reality, this is practically unimportant; we don't have enough
dashboard users to persist Shiny sessions very long.
@nmdefries nmdefries merged commit b813799 into dev Apr 14, 2023
@nmdefries nmdefries deleted the ndefries/reduce-replots-on-var-switch branch April 14, 2023 13:21
@krivard krivard mentioned this pull request Apr 26, 2023
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

Successfully merging this pull request may close these issues.

2 participants