Skip to content

Commit

Permalink
Add first pass on Galaxy API data
Browse files Browse the repository at this point in the history
  • Loading branch information
GregSutcliffe committed Sep 25, 2020
1 parent 4b4fa63 commit eb207cb
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 11 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Imports:
glue,
golem,
htmltools,
httr,
lubridate,
mongolite,
plotly,
Expand Down
75 changes: 75 additions & 0 deletions R/app_galaxy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#' Retrieve galaxy data on collection releases and do something useful with it
#'
#' @keywords internal
#' @noRd
galaxy_plot <- function(org_repo) {
repo <- stringr::str_split_fixed(org_repo,'/',2)[[2]]
if (!stringr::str_detect(repo,'\\.')) {
# base graphics
text(x = 0.5, y = 0.5, paste("No Galaxy information to display\n\n",
"Galaxy information can currently only be",
"retrieved for collections in 'x.y' format"),
cex = 1.6, col = "black")
} else {
d <- get_galaxy_info(repo)
if (class(d) == 'character') {
text(x = 0.5, y = 0.5, paste("No Galaxy information to display\n\n",
"Data retrival from Galaxy API failed\n",
"Please inform the Ansible Community Team"),
cex = 1.6, col = "black")
} else {
# ggplot2
d <- d$data$collection
r <- data.frame(
version = purrr::map_chr(d$all_versions,'version'),
created = purrr::map_chr(d$all_versions,'created') %>% lubridate::ymd_hms()
) %>%
filter(!stringr::str_detect(version,'dev|beta')) %>%
dplyr::add_row(version = 'init', created = lubridate::ymd_hms(d$created),
.before = 1) %>%
dplyr::add_row(version = 'next?', created = Sys.time()) %>%
arrange(created) %>%
dplyr::mutate(prev_version = dplyr::lag(created)) %>%
filter(!is.na(prev_version)) %>%
dplyr::mutate(release_diff = difftime(created, prev_version, units = 'days'),
colour = 'grey')

m <- median(r$release_diff)
t <- tail(r,1) %>% pull(release_diff)
c <- dplyr::if_else(t > m, '#CB333B', '#5bbdc0')
r[nrow(r),5] <- c

r %>%
dplyr::mutate(t = as.double(release_diff)) %>%
ggplot(aes(x=version, y=t, fill=I(colour))) +
geom_col() +
geom_hline(yintercept = m) +
labs(title = 'Release frequency',
subtitle = 'Horizontal line shows the median release time',
x = 'Version', y = 'Days since release',
caption = 'Source: Ansible Galaxy API') +
theme(text = element_text(size=20))
}
}

}

#' Get the Galaxy API data for a repo
#'
#' @keywords internal
#' @noRd
get_galaxy_info <- function(repo) {

match <- stringr::str_split_fixed(repo,'\\.',2)
org <- match[[1]]
repo <- match[[2]]

url <- sprintf("https://galaxy.ansible.com/api/internal/ui/repo-or-collection-detail/?namespace=%s&name=%s",org,repo)

r <- httr::GET(url)
if (r$status_code == 200) {
httr::content(r)
} else {
"Failed"
}
}
4 changes: 2 additions & 2 deletions R/app_graphs.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ issues_survival_plot <- function(d) {
g <- tibble::tibble(x = 0.95, y = 0.05, tbl = list(tbl))

plot$plot <- plot$plot +
theme(text = element_text(size=25)) +
theme(text = element_text(size=20)) +
ggpmisc::geom_table_npc(data = g, aes(npcx = x, npcy = y, label = tbl),
table.theme = ttheme) +
labs(title = 'Time-to-close for Issues & Pull Requests',
Expand Down Expand Up @@ -75,7 +75,7 @@ comments_survival_plot <- function(d) {
g <- tibble::tibble(x = 0.95, y = 0.05, tbl = list(tbl))

plot$plot <- plot$plot +
theme(text = element_text(size=25)) +
theme(text = element_text(size=20)) +
ggpmisc::geom_table_npc(data = g, aes(npcx = x, npcy = y, label = tbl),
table.theme = ttheme) +
labs(title = 'Time-to-first comment for Issues & Pull Requests',
Expand Down
4 changes: 3 additions & 1 deletion R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ app_server <- function( input, output, session ) {
repositories <- get_repos()

selectInput("repo", "Collection",
choices = repositories, selected = repositories[1])
choices = repositories,
selected = 'ansible-collections/community.general')
})

output$survival_plot <- renderPlot({
switch (input$graph_type,
'ttclose' = issues_survival_plot(repo_data()),
'ttcomment' = comments_survival_plot(repo_data()),
'galaxy' = galaxy_plot(input$repo)
)
})

Expand Down
9 changes: 3 additions & 6 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ ui_body <- function() {
selectInput("graph_type", "Metric",
choices = c(
'Time-to-close Issues/PRs' = 'ttclose',
'Time-to-first comment' = 'ttcomment'
'Time-to-first comment' = 'ttcomment',
'Galaxy releases' = 'galaxy'
),
selected = 'ttclose'
),
p(class = "text-muted",
br(),
"Time-to-release is still TODO"
),
)
),
box(width = NULL, status = "warning",
uiOutput("repoSelect"),
Expand Down
67 changes: 65 additions & 2 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@
"Repository": "CRAN",
"Hash": "b55c32ae818a84109a51f172290c95f2"
},
"covr": {
"Package": "covr",
"Version": "3.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "6d80a9fc3c0c8473153b54fa54719dfd"
},
"cowplot": {
"Package": "cowplot",
"Version": "1.1.0",
Expand Down Expand Up @@ -282,6 +289,13 @@
"Repository": "CRAN",
"Hash": "6c8fe8fa26a23b79949375d372c7b395"
},
"devtools": {
"Package": "devtools",
"Version": "2.3.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "415656f50722f5b6e6bcf80855ce11b9"
},
"digest": {
"Package": "digest",
"Version": "0.6.25",
Expand Down Expand Up @@ -646,6 +660,13 @@
"Repository": "CRAN",
"Hash": "c166f04bd2bbd830ab34b7329104c019"
},
"memoise": {
"Package": "memoise",
"Version": "1.1.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "58baa74e4603fcfb9a94401c58c8f9b1"
},
"mgcv": {
"Package": "mgcv",
"Version": "1.8-31",
Expand Down Expand Up @@ -835,6 +856,20 @@
"Repository": "CRAN",
"Hash": "5cd37ddc60f523651e84c1332d079ed4"
},
"rappdirs": {
"Package": "rappdirs",
"Version": "0.3.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "8c8298583adbbe76f3c2220eef71bebc"
},
"rcmdcheck": {
"Package": "rcmdcheck",
"Version": "1.3.3",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "ed95895886dab6d2a584da45503555da"
},
"readr": {
"Package": "readr",
"Version": "1.3.1",
Expand Down Expand Up @@ -877,6 +912,13 @@
"Repository": "CRAN",
"Hash": "7340c71f46a0fd16506cfa804e224e44"
},
"rex": {
"Package": "rex",
"Version": "1.2.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "093584b944440c5cd07a696b3c8e0e4c"
},
"rio": {
"Package": "rio",
"Version": "0.5.16",
Expand Down Expand Up @@ -919,13 +961,27 @@
"Repository": "CRAN",
"Hash": "33a5b27a03da82ac4b1d43268f80088a"
},
"rversions": {
"Package": "rversions",
"Version": "2.0.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "0ec41191f744d0f5afad8c6f35cc36e4"
},
"scales": {
"Package": "scales",
"Version": "1.1.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "6f76f71042411426ec8df6c54f34e6dd"
},
"sessioninfo": {
"Package": "sessioninfo",
"Version": "1.1.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "308013098befe37484df72c39cf90d6e"
},
"shinipsum": {
"Package": "shinipsum",
"Version": "0.0.0.9000",
Expand Down Expand Up @@ -1094,10 +1150,10 @@
},
"withr": {
"Package": "withr",
"Version": "2.2.0",
"Version": "2.3.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "ecd17882a0b4419545691e095b74ee89"
"Hash": "7307d79f58d1885b38c4f4f1a8cb19dd"
},
"xfun": {
"Package": "xfun",
Expand All @@ -1113,6 +1169,13 @@
"Repository": "CRAN",
"Hash": "d4d71a75dd3ea9eb5fa28cc21f9585e2"
},
"xopen": {
"Package": "xopen",
"Version": "1.0.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "6c85f015dee9cc7710ddd20f86881f58"
},
"xtable": {
"Package": "xtable",
"Version": "1.8-4",
Expand Down

0 comments on commit eb207cb

Please sign in to comment.