-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cc license metrics moved from email template to separate functions + …
…tests
- Loading branch information
Showing
7 changed files
with
133 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#' CC license variants metrics overview | ||
#' | ||
#' Presents normalised CC licence variants like BY (absolute and relative) | ||
#' | ||
#' @inheritParams metrics_overview | ||
#' | ||
#' @importFrom dplyr count mutate rename | ||
#' | ||
#' @export | ||
cc_metrics <- function(.md = NULL, .gt = TRUE, .color = "#F3A9BB") { | ||
if(is.null(.md) || !"cc_license_check" %in% names(.md)) | ||
stop("No compliance overview data provided, get data using cr_compliance_overview()") | ||
else | ||
out <- .md$cc_license_check %>% | ||
dplyr::count(cc_norm, name = "value") %>% | ||
dplyr::mutate(prop = value /sum(value) * 100) %>% | ||
dplyr::rename(name = cc_norm) | ||
if(.gt == FALSE) | ||
out | ||
else | ||
out %>% | ||
dplyr::mutate(prop_bar = map(prop, ~bar_chart(value = .x, .color = .color))) %>% | ||
ind_table_to_gt() | ||
} | ||
|
||
#' CC compliance metrics overview | ||
#' | ||
#' Presents the result of the CC compliance check (absolute and relative) | ||
#' | ||
#' @seealso [license_check()] | ||
#' | ||
#' @inheritParams metrics_overview | ||
#' | ||
#' @importFrom dplyr count mutate rename | ||
#' | ||
#' @export | ||
cc_compliance_metrics <- function(.md = NULL, .gt = TRUE, .color = "#A0A5A9") { | ||
if(is.null(.md) || !"cc_license_check" %in% names(.md)) | ||
stop("No compliance overview data provided, get data using cr_compliance_overview()") | ||
else | ||
out <- .md$cc_license_check %>% | ||
dplyr::count(check_result, name = "value") %>% | ||
dplyr::mutate(prop = value /sum(value) * 100) %>% | ||
dplyr::rename(name = check_result) | ||
if(.gt == FALSE) | ||
out | ||
else | ||
out %>% | ||
dplyr::mutate(prop_bar = map(prop, ~bar_chart(value = .x, .color = .color))) %>% | ||
ind_table_to_gt() | ||
} |
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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