OliverKeyes has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/258198

Change subject: Add spider information to dashboards
......................................................................

Add spider information to dashboards

What it says on the tin.

Bug: T120284
Change-Id: Ib8d12133adb3a25751932992eb2e863a0facdd46
---
M server.R
M tab_documentation/wdqs_basic.md
M ui.R
M utils.R
4 files changed, 26 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/twilightsparql 
refs/changes/98/258198/1

diff --git a/server.R b/server.R
index 215e300..1c3fe9a 100644
--- a/server.R
+++ b/server.R
@@ -18,6 +18,7 @@
     wdqs_usage %>%
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage)) %>%
       polloi::subset_by_date_range(time_frame_range(input$usage_timeframe, 
input$usage_timeframe_daterange)) %>%
+      spider_subset(val = input$include_automata) %>%
       polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Daily WDQS 
Homepage usage", group = "usage") %>%
       dyLegend(labelsDiv = "usage_legend") %>%
       dyAnnotation(as.Date("2015-09-07"), text = "A", tooltip = "WDQS 
Announced Publically")
@@ -27,6 +28,7 @@
     sparql_usage %>%
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage)) %>%
       polloi::subset_by_date_range(time_frame_range(input$usage_timeframe, 
input$usage_timeframe_daterange)) %>%
+      spider_subset(val = input$include_automata) %>%
       polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Daily 
SPARQL usage", group = "usage") %>%
       dyLegend(labelsDiv = "usage_legend") %>%
       dyAnnotation(as.Date("2015-09-07"), text = "A", tooltip = "WDQS 
Announced Publically") %>%
diff --git a/tab_documentation/wdqs_basic.md b/tab_documentation/wdqs_basic.md
index 609e841..7082483 100644
--- a/tab_documentation/wdqs_basic.md
+++ b/tab_documentation/wdqs_basic.md
@@ -1,6 +1,9 @@
 Wikidata Query Service (WDQS) usage
 =======
 
+This displays data on the use of the Wikidata Query Service (WDQS). Amongst 
other things, you can filter out automated software (or
+what looks like automated software) although this option does not operate on 
data prior to 3 December 2015.
+
 Outages and inaccuracies
 ------
 
diff --git a/ui.R b/ui.R
index 74694cb..14dd8f4 100644
--- a/ui.R
+++ b/ui.R
@@ -1,3 +1,4 @@
+source("utils.R")
 library(shiny)
 library(shinydashboard)
 library(dygraphs)
@@ -35,6 +36,7 @@
               column(polloi::timeframe_select("usage_timeframe"), width = 3),
               column(polloi::timeframe_daterange("usage_timeframe"), width = 
3),
               column(div(id = "usage_legend"), width = 3)),
+            spider_checkbox("include_automata"),
             dygraphOutput("wdqs_usage_plot", height = "200px"),
             dygraphOutput("sparql_usage_plot", height = "200px"),
             includeMarkdown("./tab_documentation/wdqs_basic.md"))
diff --git a/utils.R b/utils.R
index 4ef09bb..86356e3 100644
--- a/utils.R
+++ b/utils.R
@@ -4,17 +4,32 @@
 library(dplyr)
 
 read_wdqs <- function() {
-  data <- polloi::read_dataset("wdqs/wdqs_aggregates.tsv") %>%
-    dplyr::rename(date = timestamp) %>%
+  data <- polloi::read_dataset("wdqs/wdqs_aggregates_new.tsv") %>%
     dplyr::arrange(date)
   
   wdqs_usage <<- data %>%
     dplyr::filter(path == "/" & http_success) %>%
-    dplyr::select(c(date, events)) %>% as.data.frame
+    dplyr::select(c(date, is_automata, events)) %>% as.data.frame
   
   sparql_usage <<- data %>%
     dplyr::filter(path == "/bigdata/namespace/wdq/sparql" & http_success) %>%
-    dplyr::select(c(date, events)) %>% as.data.frame
+    dplyr::select(c(date, is_automata, events)) %>% as.data.frame
     
   return(invisible())
 }
+
+spider_checkbox <- function(input_id){
+  checkboxInput(input_id, "Include automata", value = TRUE, width = NULL)
+}
+
+spider_subset <- function(data, val){
+  
+  if(!val){
+    data <- data[!data$is_automata,]
+  }
+  
+  return({
+    data %>% group_by(date) %>%
+      summarise(events = sum(events))
+  })
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/258198
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8d12133adb3a25751932992eb2e863a0facdd46
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/twilightsparql
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

Reply via email to