Skip to content

Instantly share code, notes, and snippets.

@GuyliannEngels
Created June 9, 2020 06:07
Show Gist options
  • Select an option

  • Save GuyliannEngels/ef8d2386eb52ebb037ff91e7eecc4eff to your computer and use it in GitHub Desktop.

Select an option

Save GuyliannEngels/ef8d2386eb52ebb037ff91e7eecc4eff to your computer and use it in GitHub Desktop.
ShinyApp to visualise GitHub activity
library(shiny)
library(shinyFeedback)
library(flow)
# Cette app shiny est un outil afin de faciliter la correction des projets des étudiants. Il s'agit ici d'un MVP.
#
ui <- fluidPage(
titlePanel("Analyse du projet GitHub"),
hr(),
fluidRow(
column(width = 6,
fileInput("file", NULL, buttonLabel = "Upload...",
accept = ".Rdata"),
h4("Date de la dernière sauvegarde"),
textOutput("sys_time")),
column(width = 6,
h4("Informations générale"),
tableOutput("gen")
)),
hr(),
fluidRow(
column(width = 6,
h4("Contributeurs du projet"),
tableOutput("contributors")
),
column(width = 6,
h4("Statistiques du projet"),
tableOutput("stats")
)
),
hr(),
h4("Addition et soustraction au cours du temps"),
plotly::plotlyOutput("stats_plot"),
hr(),
h4("Commits au cours du temps"),
plotly::plotlyOutput("commits_plot"),
hr(),
h4("Commits"),
DT::dataTableOutput("commits_dt"),
hr(),
h4("Issues"),
DT::dataTableOutput("issues_dt")
)
server <- function(input, output, session) {
data <- reactive({
req(input$file)
dt <- readr::read_rds(input$file$datapath)
})
output$sys_time <- renderPrint({
dt <- data()
lubridate::as_datetime(dt$sys_time)
})
output$user <- renderPrint({
dt <- data()
dt$user
})
output$gen <- renderTable({
dt <- data()
dt <- dplyr::select(dt$general, -url)
t(dt)
}, rownames = TRUE, colnames = FALSE)
output$contributors <- renderTable({
dt <- data()
dt$contributors %>.%
dplyr::select(., login, html_url) -> contri
colnames(contri) <- c("Nom d'utilisateur", "url de l'utilisateur")
contri
})
output$stats <- renderTable({
dt <- data()
dt$stats_contributors %>.%
dplyr::mutate(., s = a - d) %>.%
dplyr::group_by(., login) %>.%
dplyr::summarise(.,
c = sum(c), a = sum(a),
d = sum(d), s = sum(s)) %>.%
dplyr::arrange(., s) -> stat
colnames(stat) <- c("Nom d’utilisateur", "Commits", "Addition", "Suppression", "Total")
stat
})
output$stats_plot <- plotly::renderPlotly({
dt <- data()
dt$stats_contributors %>.%
chart::chart(., a ~ w | login) +
ggplot2::geom_hline(yintercept = 0, color = "grey") +
ggplot2::geom_area(fill = "green") +
ggplot2::geom_area(chart::f_aes(-d~w), fill = "red") +
ggplot2::labs( y = "Addition/Suppression", x = "Temps")
})
output$commits_plot <- plotly::renderPlotly({
dt <- data()
dt$commits %>.%
dplyr::filter(., message != "Initial commit") %>.%
chart::chart(., name ~ date %group=% 1) +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::labs( y = "Nom d’utilisateur", x = "Temps")
})
output$commits_dt <- DT::renderDT({
dt <- data()
dt$commits
}, rownames = FALSE, options = list(pageLength = 5), colnames = c("Nom d'utilisateur", "Email", "Date", "Sha", "Message du commit"))
output$issues_dt <- DT::renderDT({
dt <- data()
dt$issues
}, rownames = FALSE, options = list(pageLength = 5), colnames = c("Titre", "Numéro de l'issue", "Statut", "Nom du créateur de l'issue", "Date de la création de l'issue","Nombre de commentaires"))
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment