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

duplicated available slices #377

Merged

Conversation

gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Jul 10, 2023

Closes #374

Fixes problem when adding new filter based on the variable for which there is already filter in available_teal_slices. Filters duplicated are disabled from the selection. Filter is disabled when:

  • there is already filter which is based on the same variable. Determining if filter refers to the same column is based on dataname, varname, experiment and arg. If there is any filter which has exactly the same values in all of these fields then it is duplpicated.
  • when non of these duplicated filters is active then it is possible to select any of them (nothing is disabled)
  • when any of duplicated filters is active then other (duplicated) filters are disabled

Fixed in this PR:

  • when using $set_filter_states, teal_slice attributes were changed only for datasets which had teal_slice object - loop was done on slices-datasets instead of all datasets.
  • changed slice_list_remove to accept vector instead of scalar as documentation stated character. This also matches logic in state_list_add which also accepts multiple elements.

image

@gogonzo gogonzo added the core label Jul 10, 2023
@gogonzo gogonzo linked an issue Jul 10, 2023 that may be closed by this pull request
@github-actions
Copy link
Contributor

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R/calls_combine_by.R              8       0  100.00%
R/choices_labeled.R              49      14  71.43%   22, 33, 38, 48-53, 65, 69-73
R/count_labels.R                 98       0  100.00%
R/filter_panel_api.R             37       2  94.59%   89, 101
R/FilteredData-utils.R          117      17  85.47%   103-108, 201, 223-232
R/FilteredData.R                588     217  63.10%   100-103, 276-287, 507-515, 547-548, 610-619, 641, 662-703, 721-724, 740, 781-814, 829-831, 835-841, 867-896, 918-920, 924-926, 929-940, 944-953, 955-981, 1028, 1051-1069
R/FilteredDataset-utils.R        20       1  95.00%   133
R/FilteredDataset.R             179      67  62.57%   50, 145, 194-200, 228-285, 325-327
R/FilteredDatasetDefault.R      125       9  92.80%   69, 131, 141, 145, 231-235
R/FilteredDatasetMAE.R          134      37  72.39%   27, 113-118, 157-162, 166-167, 187-209
R/FilterPanelAPI.R               10       0  100.00%
R/FilterState-utils.R           133       1  99.25%   370
R/FilterState.R                 291      45  84.54%   210, 280, 324, 617-642, 653-672, 707-713, 722-728
R/FilterStateChoices.R          337     104  69.14%   291-294, 306, 334-340, 389-396, 400-417, 459-470, 480-498, 517-520, 523-526, 537-558, 571-572, 582-586, 588-592
R/FilterStateDate.R             229     141  38.43%   216-222, 235, 285-446
R/FilterStateDatettime.R        331     218  34.14%   253-259, 273, 323-567
R/FilterStateEmpty.R             63      41  34.92%   82, 92-97, 111, 125-176
R/FilterStateExpr.R              61      48  21.31%   137-230
R/FilterStateLogical.R          216     163  24.54%   127, 150, 206-212, 220, 223-421
R/FilterStateRange.R            435     131  69.89%   251, 348-354, 362, 385, 513-517, 520-530, 533, 545-551, 562-574, 578-588, 592-594, 608-635, 650-654, 656-660, 665-669, 671-675, 692-709, 744-749, 759-761
R/FilterStates-utils.R           70       9  87.14%   102, 121, 179-185, 207, 234
R/FilterStates.R                357      30  91.60%   75-79, 188, 316-325, 407-410, 453, 538-542, 587, 699-702
R/FilterStatesDF.R                5       0  100.00%
R/FilterStatesMAE.R              10       1  90.00%   39
R/FilterStatesMatrix.R            3       0  100.00%
R/FilterStatesSE.R              201     151  24.88%   34, 97-104, 112-119, 142-289
R/include_css_js.R                5       5  0.00%    12-16
R/teal_slice-store.R              7       7  0.00%    28-57
R/teal_slice.R                   98       2  97.96%   126, 188
R/teal_slices.R                 130       1  99.23%   188
R/test_utils.R                   21       0  100.00%
R/utils.R                        49       2  95.92%   101-102
R/variable_types.R               48      33  31.25%   41-46, 56, 69-104
R/zzz.R                          15      15  0.00%    3-46
TOTAL                          4480    1512  66.25%

Diff against main

Filename                      Stmts    Miss  Cover
--------------------------  -------  ------  --------
R/calls_combine_by.R             +1       0  +100.00%
R/count_labels.R                +98       0  +100.00%
R/filter_panel_api.R            +37      +2  +94.59%
R/FilteredData-utils.R          +19     -26  +29.35%
R/FilteredData.R                +83     -50  +15.97%
R/FilteredDataset-utils.R       +20      +1  +95.00%
R/FilteredDataset.R              -9     -10  +3.53%
R/FilteredDatasetDefault.R      +19      +1  +0.35%
R/FilteredDatasetMAE.R          -74     -22  +0.75%
R/FilterPanelAPI.R              -13      -8  +34.78%
R/FilterState-utils.R           -22     -14  +8.93%
R/FilterState.R                 +64     -43  +23.30%
R/FilterStateChoices.R         +168      +8  +25.94%
R/FilterStateDate.R             +64     +33  +3.88%
R/FilterStateDatettime.R        +93     +52  +3.89%
R/FilterStateEmpty.R            +22     +25  -26.05%
R/FilterStateExpr.R             +61     +48  +21.31%
R/FilterStateLogical.R          +78     +84  -18.22%
R/FilterStateRange.R           +210      +2  +27.22%
R/FilterStates-utils.R           +2      +4  -5.50%
R/FilterStates.R               +139     -63  +34.26%
R/FilterStatesDF.R             -225     -29  +12.61%
R/FilterStatesMAE.R            -211    -105  +37.96%
R/FilterStatesMatrix.R         -214    -108  +49.77%
R/FilterStatesSE.R             -208     -50  -25.98%
R/teal_slice-store.R             +7      +7  +100.00%
R/teal_slice.R                  +98      +2  +97.96%
R/teal_slices.R                +130      +1  +99.23%
R/test_utils.R                  +21       0  +100.00%
R/utils.R                       +10       0  +1.05%
R/zzz.R                          +9      +9  +100.00%
TOTAL                          +477    -249  +9.25%

Results for commit: 6166519

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2023

Unit Tests Summary

    1 files    29 suites   30s ⏱️
368 tests 368 ✔️ 0 💤 0
813 runs  813 ✔️ 0 💤 0

Results for commit 9fa2126.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2023

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R/calls_combine_by.R              8       0  100.00%
R/choices_labeled.R              49      14  71.43%   22, 33, 38, 48-53, 65, 69-73
R/count_labels.R                 98       0  100.00%
R/filter_panel_api.R             37       2  94.59%   89, 101
R/FilteredData-utils.R          117      17  85.47%   103-108, 201, 223-232
R/FilteredData.R                569     217  61.86%   100-103, 276-287, 506-514, 546-547, 609-618, 640, 661-702, 720-723, 739, 780-813, 828-830, 834-840, 866-895, 917-919, 923-925, 928-939, 943-952, 954-980, 1027, 1050-1068
R/FilteredDataset-utils.R        20       1  95.00%   133
R/FilteredDataset.R             179      67  62.57%   50, 146, 195-201, 229-286, 326-328
R/FilteredDatasetDefault.R      121       9  92.56%   69, 131, 141, 145, 227-231
R/FilteredDatasetMAE.R          134      37  72.39%   27, 113-118, 157-162, 166-167, 187-209
R/FilterPanelAPI.R               10       0  100.00%
R/FilterState-utils.R           133       1  99.25%   370
R/FilterState.R                 291      45  84.54%   210, 280, 324, 617-642, 653-672, 707-713, 722-728
R/FilterStateChoices.R          337     104  69.14%   291-294, 306, 334-340, 389-396, 400-417, 459-470, 480-498, 517-520, 523-526, 537-558, 571-572, 582-586, 588-592
R/FilterStateDate.R             229     141  38.43%   216-222, 235, 285-446
R/FilterStateDatettime.R        331     218  34.14%   253-259, 273, 323-567
R/FilterStateEmpty.R             63      41  34.92%   82, 92-97, 111, 125-176
R/FilterStateExpr.R              61      48  21.31%   138-231
R/FilterStateLogical.R          216     163  24.54%   127, 150, 206-212, 220, 223-421
R/FilterStateRange.R            435     131  69.89%   251, 348-354, 362, 385, 513-517, 520-530, 533, 545-551, 562-574, 578-588, 592-594, 608-635, 650-654, 656-660, 665-669, 671-675, 692-709, 744-749, 759-761
R/FilterStates-utils.R           70       9  87.14%   102, 121, 179-185, 207, 234
R/FilterStates.R                360      30  91.67%   76-80, 189, 317-326, 413-416, 459, 544-548, 593, 705-708
R/FilterStatesDF.R                5       0  100.00%
R/FilterStatesMAE.R              10       1  90.00%   39
R/FilterStatesMatrix.R            3       0  100.00%
R/FilterStatesSE.R              201     151  24.88%   34, 97-104, 112-119, 142-289
R/include_css_js.R                5       5  0.00%    12-16
R/teal_slice-store.R              7       7  0.00%    28-57
R/teal_slice.R                   98       2  97.96%   128, 190
R/teal_slices.R                 133       1  99.25%   188
R/test_utils.R                   21       0  100.00%
R/utils.R                        49       2  95.92%   101-102
R/variable_types.R               48      33  31.25%   41-46, 56, 69-104
R/zzz.R                          15      15  0.00%    3-46
TOTAL                          4463    1512  66.12%

Diff against main

Filename                      Stmts    Miss  Cover
--------------------------  -------  ------  --------
R/calls_combine_by.R             +1       0  +100.00%
R/count_labels.R                +98       0  +100.00%
R/filter_panel_api.R            +37      +2  +94.59%
R/FilteredData-utils.R          +19     -26  +29.35%
R/FilteredData.R                +64     -50  +14.73%
R/FilteredDataset-utils.R       +20      +1  +95.00%
R/FilteredDataset.R              -9     -10  +3.53%
R/FilteredDatasetDefault.R      +15      +1  +0.11%
R/FilteredDatasetMAE.R          -74     -22  +0.75%
R/FilterPanelAPI.R              -13      -8  +34.78%
R/FilterState-utils.R           -22     -14  +8.93%
R/FilterState.R                 +64     -43  +23.30%
R/FilterStateChoices.R         +168      +8  +25.94%
R/FilterStateDate.R             +64     +33  +3.88%
R/FilterStateDatettime.R        +93     +52  +3.89%
R/FilterStateEmpty.R            +22     +25  -26.05%
R/FilterStateExpr.R             +61     +48  +21.31%
R/FilterStateLogical.R          +78     +84  -18.22%
R/FilterStateRange.R           +210      +2  +27.22%
R/FilterStates-utils.R           +2      +4  -5.50%
R/FilterStates.R               +142     -63  +34.33%
R/FilterStatesDF.R             -225     -29  +12.61%
R/FilterStatesMAE.R            -211    -105  +37.96%
R/FilterStatesMatrix.R         -214    -108  +49.77%
R/FilterStatesSE.R             -208     -50  -25.98%
R/teal_slice-store.R             +7      +7  +100.00%
R/teal_slice.R                  +98      +2  +97.96%
R/teal_slices.R                +133      +1  +99.25%
R/test_utils.R                  +21       0  +100.00%
R/utils.R                       +10       0  +1.05%
R/zzz.R                          +9      +9  +100.00%
TOTAL                          +460    -249  +9.12%

Results for commit: 8328234

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@@ -482,7 +482,7 @@ FilteredData <- R6::R6Class( # nolint
private$module_add <- module_add
}

lapply(datanames, function(dataname) {
lapply(self$datanames(), function(dataname) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess these lines above can be removed now:

datanames <- slices_field(state, "dataname")
checkmate::assert_subset(datanames, self$datanames())

R/FilteredData.R Outdated
Comment on lines 1098 to 1099
is_not_expr <- vapply(private$available_teal_slices(), inherits, logical(1), "teal_slice_expr")
slice_reference[is_duplicated_reference & is_active & !is_not_expr]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
is_not_expr <- vapply(private$available_teal_slices(), inherits, logical(1), "teal_slice_expr")
slice_reference[is_duplicated_reference & is_active & !is_not_expr]
is_not_expr <- !vapply(private$available_teal_slices(), inherits, logical(1), "teal_slice_expr")
slice_reference[is_duplicated_reference & is_active & is_not_expr]

R/FilteredData.R Outdated
Comment on lines 1127 to 1161
interactive_choice_mock <- lapply(
slices_interactive(),
function(slice) {
# we need to isolate changes in the fields of the slice (teal_slice)
shiny::isolate({
checkbox_group_element(
name = session$ns("available_slices_id"),
value = slice$id,
label = slice$id,
checked = if (slice$id %in% active_slices_ids) "checked",
disabled = slice$locked
disabled = slice$locked ||
get_default_slice_id(slice) %in% duplicated_slice_refs &&
!slice$id %in% active_slices_ids
)
}
)
})
}
)

non_interactive_choice_mock <- lapply(
slices_fixed(),
function(slice) {
non_interactive_choice_mock <- lapply(
slices_fixed(),
function(slice) {
# we need to isolate changes in the fields of the slice (teal_slice)
isolate(
checkbox_group_element(
name = session$ns("available_slices_id"),
value = slice$id,
label = slice$id,
checked = if (slice$id %in% active_slices_ids) "checked",
disabled = slice$locked
disabled = slice$locked ||
get_default_slice_id(slice) %in% duplicated_slice_refs &&
!slice$id %in% active_slices_ids
)
}
)
)
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps assign the function(slice) for cleaner code?

R/FilteredData.R Outdated
Comment on lines 1166 to 1169
tags$strong("Fixed filters"),
non_interactive_choice_mock,
tags$strong("Iteractive filters"),
interactive_choice_mock,
Copy link
Contributor

Choose a reason for hiding this comment

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

If the tag$strong are moved into the function that generates the mock elements, it would pre-emptively solve this bug:
image

Comment on lines 186 to 189
lapply(state, function(slice) {
checkmate::assert_true(slice$dataname == private$dataname)
})
checkmate::assert_class(state, "teal_slices")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lapply(state, function(slice) {
checkmate::assert_true(slice$dataname == private$dataname)
})
checkmate::assert_class(state, "teal_slices")
checkmate::assert_class(state, "teal_slices")
lapply(state, function(slice) {
checkmate::assert_true(slice$dataname == private$dataname)
})

fix srv_active
@gogonzo gogonzo merged commit 0ee90f3 into filter_panel_refactor@main Jul 11, 2023
23 checks passed
@gogonzo gogonzo deleted the 364_bug_fix@filter_panel_refactor@main branch July 11, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filter conflict crashes app
2 participants