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

Add Python versions chart to the Report #13

Merged
merged 8 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Package: connectViz
Title: Visualize Your 'RStudio Connect' Server Usage Data
Version: 0.0.0.9146
Authors@R:
person("David", "Granjon", , "[email protected]", role = c("aut", "cre"))
Authors@R: c(
person("David", "Granjon", , "[email protected]", role = c("aut", "cre")),
person(given = "Christophe", family = "Regouby", role = c("ctb"), email = "[email protected]")
)
Description: A collection of helper functions and 'htmlwidgets' to help admins or
user better understand how 'RStudio Connect' is used in their organization. The package
provides plug and play visualizations that can be customized depending on needs.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Suggests:
testthat (>= 3.0.0),
shinydashboard
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export(process_rsc_content)
export(process_rsc_user)
export(sort_content_by_access)
export(sort_content_by_appmode)
export(sort_content_by_pyversion)
export(sort_content_by_rversion)
export(sort_users_by_role)
import(apexcharter)
Expand Down
16 changes: 15 additions & 1 deletion R/helpers-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,21 @@ sort_content_by_rversion <- function(content) {
mutate(Percentage = round(n / sum(n) * 100, 1))
}


#' Sort RStudio Connect content by python version
#'
#'
#' @param content Get from \link[connectapi]{get_content}.
#'
#' @return A tibble with content grouped by python version.
#' @export
#' @importFrom rlang .data
sort_content_by_pyversion <- function(content) {
content %>%
filter(!is.na(.data$py_version)) %>%
group_by(.data$py_version) %>%
summarize(n = n()) %>%
mutate(Percentage = round(n / sum(n) * 100, 1))
}

#' Sort RStudio Connect content by app mode
#'
Expand Down
2 changes: 1 addition & 1 deletion R/helpers-tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ generate_table <- function(logs, sparkline = FALSE, pagination = 10, height = NU
color = ifelse(n > !!threshold, "white", "black")
) %>%
grid_summary(
column = "n",
columns = "n",
stat = "avg",
label = "Mean usage: ",
position = "top"
Expand Down
9 changes: 9 additions & 0 deletions inst/examples/simple-rmd/analysis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ r_versions <- card(
)
```

```{r content-python-version}
py_versions <- card(
full_screen = TRUE,
card_header("Python versions"),
sort_content_by_pyversion(rsc_content) |> create_pie_chart("py_version")
)
```

```{r content-type}
content_type <- card(
full_screen = TRUE,
Expand All @@ -256,6 +264,7 @@ layout_column_wrap(
user_roles,
content_access,
r_versions,
py_versions,
content_type
)
```
17 changes: 17 additions & 0 deletions man/sort_content_by_pyversion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/test-helper-charts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("create_calendar_chart works with multi years", {
dates <- seq.Date(as.Date("2017-01-01"), as.Date("2018-12-31"), by = "day")
n <- rpois(length(dates), 20)

calendar_data <- data.frame(app_name = "my_app", Date = dates, Freq = n)

expect_error(create_calendar_chart(calendar_data), NA)
})