Skip to content

1683 ignore duplicated slice#1684

Merged
gogonzo merged 6 commits intomainfrom
1683_ignore_duplicated_slice
Jan 23, 2026
Merged

1683 ignore duplicated slice#1684
gogonzo merged 6 commits intomainfrom
1683_ignore_duplicated_slice

Conversation

@gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Jan 22, 2026

another PR insightsengineering/teal.slice#675

closes https://github.com/insightsengineering/teal/issues/1683

Problem arises when trying to simplify teal-app creation from independent modules. Let's image following situation, we have a group of templates where each template has data, slices and module functions. Functions for each template are independent and they are not linked with each other. For example slices for template labs1 and labs2 are "independent" set of filters. Sometimes these filters are common filters and they should be shared by the modules - currently teal doesn't provide this, because duplicated filter id-s are raising an error. It makes sense that they will be combined and duplicated ones will be ignored.

ts_labs1 <- function() {
  teal::teal_slices(
    teal.slice::teal_slice("ds1", "var1", id = "labs_filter"),
    mapping = list(
      "lab1_module" = "labs_filter" 
    ),
    module_specific = TRUE
  )
}

ts_labs2 <- function() {
  teal::teal_slices(
    teal.slice::teal_slice("ds1", "var1", id = "labs_filter"),
    teal.slice::teal_slice("ds1", "var2", id = "labs2_filter"),
    mapping = list(
      "lab2_module" = c("labs_filter", "labs2_filter")
    ),
    module_specific = TRUE
  )
}

c(
  ts_labs1(), ts_labs2()
)

# {
#   "slices": [
#     {
#       "dataname"      : "ds1",
#       "varname"       : "var1",
#       "id"            : "labs_filter",
#       "fixed"         : false,
#       "anchored"      : false,
#       "multiple"      : true
#     },
#     {
#       "dataname"      : "ds1",
#       "varname"       : "var2",
#       "id"            : "labs2_filter",
#       "fixed"         : false,
#       "anchored"      : false,
#       "multiple"      : true
#     }
#   ],
#   "attributes": {
#     "allow_add"       : true,
#     "mapping"         : {
#       "lab1_module"   : "labs_filter",
#       "lab2_module"   : ["labs_filter", "labs2_filter"]
#     },
#     "module_specific" : true
#   }
# } ``` 

@averissimo averissimo self-assigned this Jan 22, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

Unit Tests Summary

  1 files   33 suites   2m 43s ⏱️
417 tests 356 ✅ 61 💤 0 ❌
639 runs  578 ✅ 61 💤 0 ❌

Results for commit 4d2cbdc.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

Unit Test Performance Difference

Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
teal_slices 👶 $+0.02$ c.teal_slices_combines_mapping_of_teal_slices_objects
teal_slices 👶 $+0.02$ c.teal_slices_combines_mapping_of_two_equal_slices_objects_but_ignores_adding_duplicated_one

Results for commit 7b71011

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  ---------------------------------------------------------------------------------------
R/after.R                            59      21  64.41%   42-52, 64, 69, 77-79, 81-89, 100, 104-105
R/checkmate.R                        24       0  100.00%
R/dummy_functions.R                  61       2  96.72%   54, 56
R/include_css_js.R                   11       0  100.00%
R/init.R                            136       0  100.00%
R/module_bookmark_manager.R          99      54  45.45%   78-133
R/module_data_summary.R             177       8  95.48%   40, 50, 205, 236-240
R/module_filter_data.R               64       0  100.00%
R/module_filter_manager.R           207       7  96.62%   116-117, 313, 340, 352, 359-360
R/module_init_data.R                 84       0  100.00%
R/module_nested_tabs.R              371      36  90.30%   163, 267-282, 302-306, 324, 361, 479-482, 486-489, 493-496
R/module_session_info.R              18       0  100.00%
R/module_snapshot_manager.R         272       9  96.69%   302-306, 373, 376-378
R/module_source_code.R               69       0  100.00%
R/module_teal_lockfile.R            131      53  59.54%   45-57, 60-62, 76, 86-88, 100-102, 110-119, 122, 124, 126-127, 142-146, 161-162, 177-186
R/module_teal_reporter.R            122       9  92.62%   60, 77-78, 81, 98, 128, 142, 144, 158
R/module_teal.R                     211       7  96.68%   127, 142-143, 183, 217, 260-261
R/module_transform_data.R           116       6  94.83%   48, 132-136
R/module_validate_error.R            73       0  100.00%
R/modules.R                         291      61  79.04%   170-174, 229-232, 357-377, 385, 391, 568-574, 587-595, 610-625, 658, 670-678
R/reporter_previewer_module.R        41      12  70.73%   41, 45, 68-85
R/teal_data_module-eval_code.R       23       0  100.00%
R/teal_data_module-within.R           7       0  100.00%
R/teal_data_module.R                 20       0  100.00%
R/teal_data_utils.R                  49       0  100.00%
R/teal_modifiers.R                   57       0  100.00%
R/teal_slices-store.R                29       0  100.00%
R/teal_slices.R                      48       2  95.83%   153-154
R/teal_transform_module.R            45       0  100.00%
R/TealAppDriver.R                   355     355  0.00%    50-753
R/utils.R                           291      48  83.51%   403-452, 540-549
R/validate_inputs.R                  32       0  100.00%
R/validations.R                      58       0  100.00%
R/zzz.R                              19       0  100.00%
TOTAL                              3670     690  81.20%

Diff against main

Filename             Stmts    Miss  Cover
-----------------  -------  ------  --------
R/teal_slices.R        -15      +2  -4.17%
R/TealAppDriver.R      +11     +11  +100.00%
TOTAL                   -4     +13  -0.37%

Results for commit: 4d2cbdc

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

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

We should get the namespace of those 2 functions to be teal, maybe change the environment where eval is running for environment(deep_copy_filter), my suggestion or another (better) way

Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

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

Looks good! There's on open comment, that may be moved to a discussion topic

@gogonzo
Copy link
Contributor Author

gogonzo commented Jan 23, 2026

Looks good! There's on open comment, that may be moved to a discussion topic

Let's not waste time if it covers problem for now. I just made a small improvement we can improve in the future if somebody touches these lines again

@gogonzo gogonzo merged commit ee99574 into main Jan 23, 2026
28 checks passed
@gogonzo gogonzo deleted the 1683_ignore_duplicated_slice branch January 23, 2026 13:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: c of teal.slices should treat duplicated teal_slice as a shared filters

3 participants