@@ -10,6 +10,15 @@ library(tidyr)
10
10
library(shinyjs )
11
11
library(future )
12
12
13
+ # https://devguide.python.org/versions/
14
+ PY_OLDEST_SUPPORTED <- " 3.9.0"
15
+
16
+ # https://www.tidyverse.org/blog/2019/04/r-version-support/, https://www.r-project.org/
17
+ R_OLDEST_SUPPORTED <- " 4.1.0"
18
+
19
+ # Special version that will be greater than any real version
20
+ ANY_VERSION <- " 999.99.99"
21
+
13
22
plan(multisession )
14
23
15
24
source(" get_usage.R" )
@@ -66,16 +75,16 @@ ui <- page_sidebar(
66
75
bsicons :: bs_icon(" question-circle-fill" ),
67
76
tagList(
68
77
p(
69
- " Enable a runtime filter and select a version to show " ,
70
- " items using versions older than the selected version." ,
78
+ " Enable a runtime filter and select a version range to " ,
79
+ " filter content by runtime version." ,
71
80
),
72
81
)
73
82
)
74
83
),
75
84
76
85
checkboxInput(
77
86
" use_r_cutoff" ,
78
- label = " R older than… " ,
87
+ label = " R" ,
79
88
value = FALSE
80
89
),
81
90
conditionalPanel(
@@ -89,7 +98,7 @@ ui <- page_sidebar(
89
98
90
99
checkboxInput(
91
100
" use_py_cutoff" ,
92
- label = " Python older than… " ,
101
+ label = " Python" ,
93
102
value = FALSE
94
103
),
95
104
conditionalPanel(
@@ -103,7 +112,7 @@ ui <- page_sidebar(
103
112
104
113
checkboxInput(
105
114
" use_quarto_cutoff" ,
106
- label = " Quarto older than… " ,
115
+ label = " Quarto" ,
107
116
value = FALSE
108
117
),
109
118
conditionalPanel(
@@ -115,7 +124,6 @@ ui <- page_sidebar(
115
124
)
116
125
),
117
126
118
- # h5("Filters"),
119
127
tags $ hr(),
120
128
121
129
selectizeInput(
@@ -132,22 +140,16 @@ ui <- page_sidebar(
132
140
133
141
div(
134
142
class = " form-group shiny-input-container" ,
135
- # tags$label(
136
- # "Viewed at least…",
137
- # style = "margin-bottom: 8px; display: inline-block;"
138
- # ),
139
143
div(
140
- # this div is getting a height of 52.6
141
144
style = " display: flex; align-items: baseline; gap: 6px; height: 36.5px" ,
142
145
numericInput(
143
- # this control has a height of 36.5
144
146
" min_views_filter" ,
145
147
label = NULL ,
146
148
value = 0 ,
147
149
min = 0 ,
148
150
width = " 80px" ,
149
151
),
150
- span(" times" ) # this span has a height of 24
152
+ span(" times" )
151
153
)
152
154
),
153
155
@@ -236,15 +238,20 @@ server <- function(input, output, session) {
236
238
filter(runtime == " quarto" ) | >
237
239
pull(version )
238
240
241
+ # Include EOL versions and ANY_VERSION in the additional versions
242
+ r_additional_vers <- c(r_server_vers , R_OLDEST_SUPPORTED , ANY_VERSION )
243
+ py_additional_vers <- c(py_server_vers , PY_OLDEST_SUPPORTED , ANY_VERSION )
244
+ quarto_additional_vers <- c(quarto_server_vers , ANY_VERSION )
245
+
239
246
content <- get_content(client ) | >
240
247
filter(app_role %in% c(" owner" , " editor" )) | >
241
248
mutate(
242
249
owner_username = map_chr(owner , " username" ),
243
- r_version = as_ordered_version_factor(r_version , r_server_vers ),
244
- py_version = as_ordered_version_factor(py_version , py_server_vers ),
250
+ r_version = as_ordered_version_factor(r_version , r_additional_vers ),
251
+ py_version = as_ordered_version_factor(py_version , py_additional_vers ),
245
252
quarto_version = as_ordered_version_factor(
246
253
quarto_version ,
247
- quarto_server_vers
254
+ quarto_additional_vers
248
255
),
249
256
)
250
257
})
@@ -257,27 +264,62 @@ server <- function(input, output, session) {
257
264
pv <- levels(content()$ py_version )
258
265
qv <- levels(content()$ quarto_version )
259
266
267
+ # Create named vectors for the dropdown choices
268
+ r_choices <- rv
269
+ py_choices <- pv
270
+ quarto_choices <- qv
271
+
272
+ # Special version labels
273
+ r_eol_label <- paste0(" tidyverse EOL (< " , R_OLDEST_SUPPORTED , " )" )
274
+ py_eol_label <- paste0(" Official EOL (< " , PY_OLDEST_SUPPORTED , " )" )
275
+ any_version_label <- " Any version"
276
+
277
+ # Format labels for all normal versions
278
+ format_version_label <- function (version ) {
279
+ if (version == ANY_VERSION ) {
280
+ return (any_version_label )
281
+ } else {
282
+ return (paste0(" < " , version ))
283
+ }
284
+ }
285
+
286
+ # Create names for all choices with formatted labels
287
+ names(r_choices ) <- sapply(r_choices , format_version_label )
288
+ names(py_choices ) <- sapply(py_choices , format_version_label )
289
+ names(quarto_choices ) <- sapply(quarto_choices , format_version_label )
290
+
291
+ # Find the EOL versions and add special labels
292
+ r_eol_index <- which(r_choices == R_OLDEST_SUPPORTED )
293
+ py_eol_index <- which(py_choices == PY_OLDEST_SUPPORTED )
294
+
295
+ if (length(r_eol_index ) > 0 ) {
296
+ names(r_choices )[r_eol_index ] <- r_eol_label
297
+ }
298
+ if (length(py_eol_index ) > 0 ) {
299
+ names(py_choices )[py_eol_index ] <- py_eol_label
300
+ }
301
+
260
302
# Update the R version input
261
303
updateSelectizeInput(
262
304
session ,
263
305
" r_version_cutoff" ,
264
- choices = I( rv ) ,
265
- selected = if (length(rv ) > 0 ) rv [length( rv ) ] else NULL
306
+ choices = r_choices ,
307
+ selected = if (length(rv ) > 0 ) rv [r_eol_index ] else NULL
266
308
)
267
309
268
310
# Update the Python version input
269
311
updateSelectizeInput(
270
312
session ,
271
313
" py_version_cutoff" ,
272
- choices = I( pv ) ,
273
- selected = if (length(pv ) > 0 ) pv [length( pv ) ] else NULL
314
+ choices = py_choices ,
315
+ selected = if (length(pv ) > 0 ) pv [py_eol_index ] else NULL
274
316
)
275
317
276
318
# Update the Quarto version input
277
319
updateSelectizeInput(
278
320
session ,
279
321
" quarto_version_cutoff" ,
280
- choices = I( qv ) ,
322
+ choices = quarto_choices ,
281
323
selected = if (length(qv ) > 0 ) qv [length(qv )] else NULL
282
324
)
283
325
},
@@ -345,13 +387,20 @@ server <- function(input, output, session) {
345
387
return (base )
346
388
}
347
389
348
- base | >
390
+ # Apply filters based on runtime version cutoffs
391
+
392
+ # Apply the filter
393
+ result <- base | >
349
394
# fmt: skip
350
395
filter(
351
396
(input $ use_r_cutoff & r_version < input $ r_version_cutoff ) |
352
397
(input $ use_py_cutoff & py_version < input $ py_version_cutoff ) |
353
398
(input $ use_quarto_cutoff & quarto_version < input $ quarto_version_cutoff )
354
399
)
400
+
401
+ # Return the filtered results
402
+
403
+ result
355
404
})
356
405
357
406
output $ selected_versions_html <- renderUI({
@@ -381,18 +430,33 @@ server <- function(input, output, session) {
381
430
# Single filter case
382
431
if (active_filters == 1 ) {
383
432
if (input $ use_r_cutoff ) {
433
+ label <- if (rv == ANY_VERSION ) {
434
+ " any R version"
435
+ } else {
436
+ paste0(" R version < " , rv )
437
+ }
384
438
return (tags $ p(HTML(glue :: glue(
385
- " Showing {total_count} items using R older than <span class='number-pre'>{rv}</span> ."
439
+ " Showing {total_count} items using {label} ."
386
440
))))
387
441
}
388
442
if (input $ use_py_cutoff ) {
443
+ label <- if (pv == ANY_VERSION ) {
444
+ " any Python version"
445
+ } else {
446
+ paste0(" Python version < " , pv )
447
+ }
389
448
return (tags $ p(HTML(glue :: glue(
390
- " Showing {total_count} items using Python older than <span class='number-pre'>{pv}</span> ."
449
+ " Showing {total_count} items using {label} ."
391
450
))))
392
451
}
393
452
if (input $ use_quarto_cutoff ) {
453
+ label <- if (qv == ANY_VERSION ) {
454
+ " any Quarto version"
455
+ } else {
456
+ paste0(" Quarto version < " , qv )
457
+ }
394
458
return (tags $ p(HTML(glue :: glue(
395
- " Showing {total_count} items using Quarto older than <span class='number-pre'>{qv}</span> ."
459
+ " Showing {total_count} items using {label} ."
396
460
))))
397
461
}
398
462
}
@@ -423,18 +487,33 @@ server <- function(input, output, session) {
423
487
# Create list items for multiple filters
424
488
li_items <- list ()
425
489
if (input $ use_r_cutoff ) {
490
+ r_label <- if (rv == ANY_VERSION ) {
491
+ " Any R version"
492
+ } else {
493
+ paste0(" R version < " , rv )
494
+ }
426
495
li_items [[length(li_items ) + 1 ]] <- tags $ li(HTML(glue :: glue(
427
- " R older than <span class='number-pre'>{rv}</span> ({r_count} items)"
496
+ " {r_label} ({r_count} items)"
428
497
)))
429
498
}
430
499
if (input $ use_py_cutoff ) {
500
+ py_label <- if (pv == ANY_VERSION ) {
501
+ " Any Python version"
502
+ } else {
503
+ paste0(" Python version < " , pv )
504
+ }
431
505
li_items [[length(li_items ) + 1 ]] <- tags $ li(HTML(glue :: glue(
432
- " Python older than <span class='number-pre'>{pv}</span> ({py_count} items)"
506
+ " {py_label} ({py_count} items)"
433
507
)))
434
508
}
435
509
if (input $ use_quarto_cutoff ) {
510
+ quarto_label <- if (qv == ANY_VERSION ) {
511
+ " Any Quarto version"
512
+ } else {
513
+ paste0(" Quarto version < " , qv )
514
+ }
436
515
li_items [[length(li_items ) + 1 ]] <- tags $ li(HTML(glue :: glue(
437
- " Quarto older than <span class='number-pre'>{qv}</span> ({quarto_count} items)"
516
+ " {quarto_label} ({quarto_count} items)"
438
517
)))
439
518
}
440
519
@@ -563,6 +642,7 @@ server <- function(input, output, session) {
563
642
session $ sendCustomMessage(" setGuidVisible" , input $ show_guid )
564
643
})
565
644
645
+
566
646
# Download handler
567
647
output $ export_data <- downloadHandler(
568
648
filename = function () {
0 commit comments