OliverKeyes has uploaded a new change for review. https://gerrit.wikimedia.org/r/260428
Change subject: Switch dashboard for Maps over to detect automata ...................................................................... Switch dashboard for Maps over to detect automata Pairs with the patch to the data retrieval scripts. Don't deploy it yet, I need to smush the datasets together. Bug: T121758 Change-Id: If021bd521afa7b32c474526daeb5c0fbc20d39a6 --- M server.R M ui.R M utils.R 3 files changed, 42 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/wetzel refs/changes/28/260428/1 diff --git a/server.R b/server.R index 457b2cd..c3de516 100644 --- a/server.R +++ b/server.R @@ -18,7 +18,7 @@ } output$tiles_summary_series <- renderDygraph({ - temp <- ddply(tiles_data, .(date), summarize, + temp <- ddply(data_select(input$tile_summary_automata_check, new_tiles_automata, new_tiles_no_automata), .(date), summarize, `total tiles` = sum(total), `total users` = sum(users), `average tiles per user` = `total tiles` / `total users`) @@ -36,8 +36,10 @@ tooltip = "Maps launch announcement", width = 100, height = 25, attachAtBottom = TRUE) }) + output$tiles_style_series <- renderDygraph({ - ddply(tiles_data, .(date, style), summarize, `total tiles` = sum(total)) %>% + ddply(data_select(input$tile_style_automata_check, new_tiles_automata, new_tiles_no_automata), + .(date, style), summarize, `total tiles` = sum(total)) %>% tidyr::spread(style, `total tiles`) %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_tiles_style_series)) %>% polloi::subset_by_date_range(time_frame_range(input$tiles_style_series_timeframe, input$tiles_style_series_timeframe_daterange)) %>% @@ -47,8 +49,10 @@ tooltip = "Maps launch announcement", width = 100, height = 25, attachAtBottom = TRUE) }) + output$tiles_users_series <- renderDygraph({ - ddply(tiles_data, .(date, style), summarize, `total users` = sum(users)) %>% + ddply(data_select(input$tile_users_automata_check, new_tiles_automata, new_tiles_no_automata), + .(date, style), summarize, `total users` = sum(users)) %>% tidyr::spread(style, `total users`) %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_tiles_users_series)) %>% polloi::subset_by_date_range(time_frame_range(input$tiles_users_series_timeframe, input$tiles_users_series_timeframe_daterange)) %>% @@ -58,13 +62,15 @@ tooltip = "Maps launch announcement", width = 100, height = 25, attachAtBottom = TRUE) }) + output$zoom_level_selector_container <- renderUI({ selectInput("zoom_level_selector", "Zoom level", multiple = TRUE, selected = "0", selectize = FALSE, size = 19, choices = as.character(sort(unique(tiles_data$zoom)))) }) + output$tiles_zoom_series <- renderDygraph({ - tiles_data %>% + data_select(input$tile_zoom_automata_check, new_tiles_automata, new_tiles_no_automata) %>% subset(zoom %in% as.numeric(input$zoom_level_selector)) %>% ddply(.(date, zoom), summarize, `total tiles` = sum(total)) %>% tidyr::spread(zoom, `total tiles`) %>% diff --git a/ui.R b/ui.R index 965e375..8996079 100644 --- a/ui.R +++ b/ui.R @@ -4,6 +4,10 @@ header <- dashboardHeader(title = "Wikimedia Maps", dropdownMenuOutput("message_menu"), disable = FALSE) +spider_check <- function(id_name){ + shiny::checkboxInput(id_name, label = "Include automata", value = TRUE) +} + sidebar <- dashboardSidebar( tags$head( tags$link(rel = "stylesheet", type = "text/css", href = "stylesheet.css"), @@ -42,6 +46,7 @@ column(polloi::smooth_select("smoothing_tiles_summary_series"), width = 3), column(polloi::timeframe_select("tiles_summary_series_timeframe"), width = 3), column(polloi::timeframe_daterange("tiles_summary_series_timeframe"), width = 4)), + spider_check("tile_summary_automata_check"), dygraphOutput("tiles_summary_series"), div(id = "tiles_summary_series_legend", style = "text-align: right;"), includeMarkdown("./tab_documentation/tiles_summary.md")), @@ -50,6 +55,7 @@ column(polloi::smooth_select("smoothing_tiles_style_series"), width = 4), column(polloi::timeframe_select("tiles_style_series_timeframe"), width = 4), column(polloi::timeframe_daterange("tiles_style_series_timeframe"), width = 4)), + spider_check("tile_style_automata_check"), dygraphOutput("tiles_style_series"), div(id = "tiles_style_series_legend", style = "text-align: right;"), includeMarkdown("./tab_documentation/tiles_total_by_style.md")), @@ -58,6 +64,7 @@ column(polloi::smooth_select("smoothing_tiles_users_series"), width = 4), column(polloi::timeframe_select("tiles_users_series_timeframe"), width = 4), column(polloi::timeframe_daterange("tiles_users_series_timeframe"), width = 4)), + spider_check("tile_users_automata_check"), dygraphOutput("tiles_users_series"), div(id = "tiles_users_series_legend", style = "text-align: right;"), includeMarkdown("./tab_documentation/tiles_users_by_style.md")), @@ -68,6 +75,7 @@ column(polloi::timeframe_daterange("tiles_zoom_series_timeframe"), width = 4)), fluidRow(column(uiOutput("zoom_level_selector_container"), width = 3), column(dygraphOutput("tiles_zoom_series"), width = 8)), + spider_check("tile_zoom_automata_check"), div(id = "tiles_zoom_series_legend", style = "text-align: right;"), includeMarkdown("./tab_documentation/tiles_total_by_zoom.md")), tabItem(tabName = "platform_usage", diff --git a/utils.R b/utils.R index 4497270..ed6c827 100644 --- a/utils.R +++ b/utils.R @@ -1,8 +1,9 @@ # Dependencies -library(plyr) +library(dplyr) library(magrittr) library(reshape2) library(polloi) +library(data.table) # Read in action data and write it into the global scope with sufficient formatting to be trivially # used in dygraphs. @@ -26,7 +27,27 @@ } read_tiles <- function() { - interim <- polloi::read_dataset("maps/tile_aggregates.tsv", col_types = "Dcidcciidiii") - tiles_data <<- interim + tiles_data <<- polloi::read_dataset("maps/tile_aggregates.tsv", col_types = "Dcidcciidiii") + new_tiles_data <- as.data.table(polloi::read_dataset("maps/tile_aggregates_new.tsv", col_types = "Dcidcclii")) + + new_tiles_automata <- new_tiles_data[,list(users = sum(users), total = sum(n), average = round(mean(n)), + median = ceiling(median(n)), percentile95 = ceiling(quantile(n, 0.95)), + percentile99 = ceiling(quantile(n, 0.99))), + by = c("date", "style", "zoom", "scale", "format", "cache")] + + new_tiles_no_automata <<- new_tiles_data[new_tiles_data$is_automata == FALSE, + list(users = sum(users), total = sum(n),average = round(mean(n)), + median = ceiling(median(n)), percentile95 = ceiling(quantile(n, 0.95)), + percentile99 = ceiling(quantile(n, 0.99))), + by = c("date", "style", "zoom", "scale", "format", "cache")] + + return(invisible()) } + +data_select <- function(condition, true_set, false_set){ + if(condition){ + return(true_set) + } + return(false_set) +} -- To view, visit https://gerrit.wikimedia.org/r/260428 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If021bd521afa7b32c474526daeb5c0fbc20d39a6 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/discovery/wetzel Gerrit-Branch: master Gerrit-Owner: OliverKeyes <oke...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits