Bearloga has uploaded a new change for review. https://gerrit.wikimedia.org/r/271941
Change subject: Adds option to group browser versions ...................................................................... Adds option to group browser versions What it says on the tin. Change-Id: Idb1acd86f819b0c6c10014372405db39c9f5d215 --- M functions.R M server.R M ui.R 3 files changed, 43 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/prince refs/changes/41/271941/1 diff --git a/functions.R b/functions.R index 28f855f..0433c9f 100644 --- a/functions.R +++ b/functions.R @@ -32,14 +32,18 @@ read_useragents <- function(){ data <- as.data.table(polloi::read_dataset(path = "portal/user_agent_data.tsv")) - data$browser <- paste(data$browser, data$version) - data$version <- NULL - data <- data[order(data$date, data$browser),,] + data$version <- paste(data$browser, data$version) + data <- data[order(data$date, data$version),,] ua_data <<- data - browser_rates <<- data[, list(rate = get_exp_rate(date, percent), + interim <- data[, list(percent = sum(percent)), by = c("date", "browser")] + browser_rates <<- interim[, list(rate = get_exp_rate(date, percent), + last = tail(percent, 1), + times = length(percent)), + by = "browser"] + version_rates <<- data[, list(rate = get_exp_rate(date, percent), last = tail(percent, 1), times = length(percent)), - by = "browser"] + by = "version"] } read_pageviews <- function(){ diff --git a/server.R b/server.R index 436cbd5..59a1ae2 100644 --- a/server.R +++ b/server.R @@ -62,19 +62,39 @@ output$browser_selector_container <- renderUI({ browsers <- switch(input$browser_order, "alphabet" = { - sort(browser_rates$browser) + if (input$group_browsers) { + sort(browser_rates$browser, na.last = TRUE) + } else { + sort(version_rates$version, na.last = TRUE) + } }, "growth" = { - browser_rates$browser[order(browser_rates$rate, decreasing = TRUE)] + if (input$group_browsers) { + browser_rates$browser[order(browser_rates$rate, decreasing = TRUE, na.last = TRUE)] + } else { + version_rates$version[order(version_rates$rate, decreasing = TRUE, na.last = TRUE)] + } }, "decay" = { - browser_rates$browser[order(browser_rates$rate, decreasing = FALSE)] + if (input$group_browsers) { + browser_rates$browser[order(browser_rates$rate, decreasing = FALSE, na.last = TRUE)] + } else { + version_rates$version[order(version_rates$rate, decreasing = FALSE, na.last = TRUE)] + } }, "last" = { - browser_rates$browser[order(browser_rates$last, decreasing = TRUE)] + if (input$group_browsers) { + browser_rates$browser[order(browser_rates$last, decreasing = TRUE, na.last = TRUE)] + } else { + version_rates$version[order(version_rates$last, decreasing = TRUE, na.last = TRUE)] + } }, "times" = { - browser_rates$browser[order(browser_rates$times, decreasing = TRUE)] + if (input$group_browsers) { + browser_rates$browser[order(browser_rates$times, decreasing = TRUE, na.last = TRUE)] + } else { + version_rates$version[order(version_rates$times, decreasing = TRUE, na.last = TRUE)] + } }) if (input$browser_filter != "") { if (grepl(",\\s?", input$browser_filter, fixed = FALSE)) { @@ -97,8 +117,14 @@ }) output$browser_breakdown_dygraph <- renderDygraph({ - ua_data[ua_data$browser %in% input$browser_selector, , ] %>% - reshape2::dcast(date ~ browser, fun.aggregate = sum) %>% + if (input$group_browsers) { + temp <- ua_data[ua_data$browser %in% input$browser_selector, , ] %>% + reshape2::dcast(date ~ browser, fun.aggregate = sum) + } else { + temp <- ua_data[ua_data$version %in% input$browser_selector, , ] %>% + reshape2::dcast(date ~ version, fun.aggregate = sum) + } + temp %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_browser_breakdown)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Share (%)", title = "Browser breakdown of portal visitors") %>% dyCSS(css = "www/inverse.css") %>% diff --git a/ui.R b/ui.R index da8bbef..692e0e1 100644 --- a/ui.R +++ b/ui.R @@ -66,6 +66,7 @@ "Number of times it appears in data" = "times")), textInput("browser_filter", "Filter", placeholder = "IE, firefox"), helpText("Case insensitive & accepts comma-separated input."), + checkboxInput("group_browsers", "Group browser versions", FALSE), uiOutput("browser_selector_container"), width = 3), column(div(polloi::smooth_select("smoothing_browser_breakdown"), -- To view, visit https://gerrit.wikimedia.org/r/271941 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idb1acd86f819b0c6c10014372405db39c9f5d215 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/discovery/prince Gerrit-Branch: master Gerrit-Owner: Bearloga <mpo...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits