Bearloga has submitted this change and it was merged.
Change subject: Switch wetzel over to polloi
......................................................................
Switch wetzel over to polloi
Switches the maps dashboards over to use the common functionality
in polloi.
Bug: T112700
Change-Id: I71519484f61a5134d3b7f0552f2c12d4f0632e05
---
M server.R
M utils.R
2 files changed, 8 insertions(+), 49 deletions(-)
Approvals:
Bearloga: Verified; Looks good to me, approved
diff --git a/server.R b/server.R
index 5e45dc0..b8cdffe 100644
--- a/server.R
+++ b/server.R
@@ -8,7 +8,7 @@
read_actions <- function(){
# Read in data, split and rename it, and write it o
- data <- download_set("actions_per_tool.tsv")
+ data <- polloi::read_dataset("maps/actions_per_tool.tsv")
data <- split(data[,c(1,3,4)], data$feature)
usage_data <<- lapply(data, reshape2::dcast, formula = timestamp ~ variable,
fun.aggregate = sum)
return(invisible())
@@ -16,7 +16,7 @@
# Read in user count
read_users <- function(){
- data <- download_set("users_per_feature.tsv")
+ data <- polloi::read_dataset("maps/users_per_feature.tsv")
interim <- reshape2::dcast(data, formula = timestamp ~ variable,
fun.aggregate = sum)
interim[is.na(interim)] <- 0
user_data <<- interim
@@ -32,27 +32,27 @@
existing_date <<- Sys.Date()
}
- output$users_per_platform <- renderDygraph(make_dygraph(
+ output$users_per_platform <- renderDygraph(polloi::make_dygraph(
user_data, "Date", "Events",
"Unique users by platform, by day"
))
- output$geohack_feature_usage <- renderDygraph(make_dygraph(
+ output$geohack_feature_usage <- renderDygraph(polloi::make_dygraph(
usage_data$GeoHack, "Date", "Events",
"Feature usage for GeoHack"
))
- output$wikiminiatlas_feature_usage <- renderDygraph(make_dygraph(
+ output$wikiminiatlas_feature_usage <- renderDygraph(polloi::make_dygraph(
usage_data$WikiMiniAtlas, "Date", "Events",
"Feature usage for WikiMiniAtlas"
))
- output$wikivoyage_feature_usage <- renderDygraph(make_dygraph(
+ output$wikivoyage_feature_usage <- renderDygraph(polloi::make_dygraph(
usage_data$Wikivoyage, "Date", "Events",
"Feature usage for Wikivoyage"
))
- output$wiwosm_feature_usage <- renderDygraph(make_dygraph(
+ output$wiwosm_feature_usage <- renderDygraph(polloi::make_dygraph(
usage_data$WIWOSM, "Date", "Events",
"Feature usage for WIWOSM"
))
diff --git a/utils.R b/utils.R
index de5af6c..0a115da 100644
--- a/utils.R
+++ b/utils.R
@@ -1,46 +1,5 @@
# Dependencies
-library(readr)
-library(xts)
library(reshape2)
-library(RColorBrewer)
-library(ggplot2)
-library(toOrdinal)
-library(lubridate)
-library(magrittr)
-
-#Utility functions for handling particularly common tasks
-download_set <- function(location){
- location <- paste0("http://datasets.wikimedia.org/aggregate-datasets/maps/",
location,
- "?ts=", gsub(x = Sys.time(), pattern = "(-| )",
replacement = ""))
- con <- url(location)
- return(readr::read_delim(con, delim = "\t"))
-}
-
-#Create a dygraph using our standard format.
-make_dygraph <- function(data, x, y, title, is_single = FALSE, legend_name =
NULL, use_si = TRUE){
-
- if(is_single || length(unique(data[,2])) == 1){
- data <- xts(data[,3], data[[1]])
- if(is.null(legend_name)){
- names(data) <- "events"
- } else {
- names(data) <- legend_name
- }
-
- } else if(ncol(data) < 3){
- name <- names(data)[2]
- data <- xts(data[,-1], order.by = data[[1]])
- names(data) <- name
- } else {
- data <- xts(data[,-1], order.by = data[[1]])
- }
- return(dygraph(data, main = title, xlab = x, ylab = y) %>%
- dyLegend(width = 400, show = "always") %>%
- dyOptions(strokeWidth = 3,
- colors = brewer.pal(max(3,ncol(data)), "Set2"),
- drawPoints = FALSE, pointSize = 3, labelsKMB = use_si,
- includeZero = TRUE) %>%
- dyCSS(css = "./assets/css/custom.css"))
-}
+library(polloi)
--
To view, visit https://gerrit.wikimedia.org/r/239880
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I71519484f61a5134d3b7f0552f2c12d4f0632e05
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/wetzel
Gerrit-Branch: master
Gerrit-Owner: OliverKeyes <[email protected]>
Gerrit-Reviewer: Bearloga <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits