-
Notifications
You must be signed in to change notification settings - Fork 11
fix: R script and settings export missing volume unit simplification (#1190) #1228
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
Draft
Gero1999
wants to merge
25
commits into
main
Choose a base branch
from
1190-fix/units-table-detect-changes-by-value
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6a3272d
refactor: detect unit changes by comparing PPSTRESU vs PPORRESU
Gero1999 f750289
refactor: remove default flag from units table modal open logic
Gero1999 dc64958
refactor: remove default column from reactable and edit handler
Gero1999 be27b41
refactor: remove default flag filtering from settings export
Gero1999 339b559
refactor: remove default flag from global units_table observer
Gero1999 aa406cd
cleanup: remove residual default column guards
Gero1999 b66eec9
chore: bump version to 0.1.0.9150 and update NEWS.md
Gero1999 4b4de94
fix: auto-populate units_table from simplified PKNCAdata units
Gero1999 5b9b913
fix: exclude NA rows from units change detection
Gero1999 e372eb1
address if the user loads new data with no unit diffs after previous…
Gero1999 f4f71d2
fix: store full units table internally, filter to changed rows on export
Gero1999 d8b6875
fix: merge imported units into full data-derived table on settings up…
Gero1999 a6de2cf
Merge branch 'main' into 1190-fix/units-table-detect-changes-by-value
Gero1999 9d9f9c4
Bump version to 0.1.0.9153
Gero1999 8b53792
refactor: reduce cyclomatic complexity of tab_nca_server
Gero1999 1f311a3
Merge branch 'main' into 1190-fix/units-table-detect-changes-by-value
Gero1999 f84ee0f
Merge remote-tracking branch 'origin/main' into 1190-fix/units-table-…
Gero1999 840102e
revert: remove auto-replay system, keep only units-table changes
Gero1999 c511bd1
Merge main into 1190-fix/units-table-detect-changes-by-value
Gero1999 5b501d3
fix: isolate settings_override read in units auto-populate observer
Gero1999 6b6a464
Merge main into branch
Gero1999 6b0dcfd
refactor: extract .sync_units_table to reduce tab_nca_server complexity
Gero1999 e6ebd6d
fix: simplify .sync_units_table to avoid auto-replay interference
Gero1999 a57dcc4
fix: populate units_table lazily inside res_nca instead of observer
Gero1999 e94ce34
fix: decouple units_table from settings() reactive to prevent debounc…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,20 @@ tab_nca_server <- function(id, pknca_data, extra_group_vars, settings_override) | |
| #' should respect the units, regardless of location. | ||
| session$userData$units_table <- reactiveVal(NULL) | ||
|
|
||
| # Keep units_table synchronized with the current dataset. Store the full | ||
| # units table so downstream code never receives a partial units table, and | ||
| # clear it when no units are available to avoid stale values persisting | ||
| # across uploads. | ||
| observeEvent(pknca_data(), { | ||
| current_pknca_data <- pknca_data() | ||
|
|
||
| if (is.null(current_pknca_data) || is.null(current_pknca_data$units)) { | ||
| session$userData$units_table(NULL) | ||
| return() | ||
| } | ||
|
|
||
| session$userData$units_table(current_pknca_data$units) | ||
| }, ignoreNULL = FALSE) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: add a blank line between the |
||
| adnca_data <- reactive(pknca_data()$conc$data) | ||
|
|
||
| # #' NCA Setup module | ||
|
|
@@ -136,9 +150,7 @@ tab_nca_server <- function(id, pknca_data, extra_group_vars, settings_override) | |
| # Update units table | ||
| processed_pknca_data <- processed_pknca_data() | ||
| if (!is.null(session$userData$units_table())) { | ||
| custom_units <- select( | ||
| session$userData$units_table(), -any_of("default") | ||
| ) | ||
| custom_units <- session$userData$units_table() | ||
| by_cols <- intersect(names(processed_pknca_data$units), names(custom_units)) | ||
| by_cols <- setdiff(by_cols, c("PPSTRESU", "conversion_factor")) | ||
| processed_pknca_data$units <- rows_update( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This observer fires on every
pknca_data()invalidation and unconditionally overwritesunits_tablewith the data-derived defaults. Meanwhile,nca_setup.R:175has abindEvent(processed_pknca_data(), once = TRUE)observer that merges imported settings intounits_table.If both observers flush in the same cycle (which happens when
pknca_data()andprocessed_pknca_data()invalidate together during settings import), the execution order is undefined. If this observer runs after the settings import observer, it overwrites the merged units with plain defaults — silently discarding the imported unit overrides.Two possible fixes:
Option A — priority ordering:
Actually, Shiny runs higher-priority observers first. So set this observer to a lower priority so it runs first, then the settings import observer runs after and overwrites with the merged result:
Option B (preferred) — skip when settings import is pending:
observeEvent(pknca_data(), { current_pknca_data <- pknca_data() if (is.null(current_pknca_data) || is.null(current_pknca_data$units)) { session$userData$units_table(NULL) return() } # Don't overwrite if a settings import already populated the table # with user-customized units for this dataset if (is.null(session$userData$units_table())) { session$userData$units_table(current_pknca_data$units) } }, ignoreNULL = FALSE)Option B is simpler and avoids the priority dance. The settings import observer will still merge on top when
processed_pknca_data()fires, and on re-uploadunits_tableis cleared toNULLfirst (line 98-99), so the guard passes correctly.