Chelsyx has submitted this change and it was merged.

Change subject: Show all available KPI data
......................................................................


Show all available KPI data

+ Adds option to view all available date for KPIs
  (in addition to 7/30/60/90 days)

Change-Id: I168ade47e60cd11be175eb1527f2752197361297
---
M server.R
M tab_documentation/kpis_summary.md
M ui.R
3 files changed, 53 insertions(+), 14 deletions(-)

Approvals:
  Chelsyx: Verified; Looks good to me, approved



diff --git a/server.R b/server.R
index 339306b..127b429 100644
--- a/server.R
+++ b/server.R
@@ -406,6 +406,9 @@
   output$kpi_summary_date_range <- renderUI({
     date_range <- input$kpi_summary_date_range_selector
     switch(date_range,
+           all = {
+             return(NULL)
+           },
            daily = {
              dates <- Sys.Date() - c(1, 2)
              temp <- dates %>%
@@ -455,6 +458,9 @@
 
   output$kpi_summary_box_load_time <- renderValueBox({
     date_range <- input$kpi_summary_date_range_selector
+    if (date_range == "all") {
+      return(valueBox(subtitle = "Load time", value = "N/A", color = "black"))
+    }
     x <- list(desktop_load_data, mobile_load_data, android_load_data, 
ios_load_data) %>%
       lapply(polloi::subset_by_date_range, from = start_date(date_range), to = 
Sys.Date() - 1) %>%
       lapply(function(data_tail) return(data_tail$Median))
@@ -477,6 +483,9 @@
   })
   output$kpi_summary_box_zero_results <- renderValueBox({
     date_range <- input$kpi_summary_date_range_selector
+    if (date_range == "all") {
+      return(valueBox(subtitle = "Zero results rate", value = "N/A", color = 
"black"))
+    }
     x <- polloi::subset_by_date_range(failure_data_with_automata, from = 
start_date(date_range), to = Sys.Date() - 1)
     x <- transform(x, Rate = rate)$Rate
     if (date_range == "quarterly") {
@@ -499,6 +508,9 @@
   })
   output$kpi_summary_box_api_usage <- renderValueBox({
     date_range <- input$kpi_summary_date_range_selector
+    if (date_range == "all") {
+      return(valueBox(subtitle = "API usage", value = "N/A", color = "black"))
+    }
     x <- split_dataset %>%
       lapply(polloi::subset_by_date_range, from = start_date(date_range), to = 
Sys.Date() - 1) %>%
       lapply(function(x) return(x$events)) %>%
@@ -522,11 +534,9 @@
   })
   output$kpi_summary_box_augmented_clickthroughs <- renderValueBox({
     date_range <- input$kpi_summary_date_range_selector
-    #========= We can delete this block after we get 90 days of data =========
-    if ( (date_range == "monthly" && (Sys.Date()-1)-60 < 
as.Date("2015-09-02")) || date_range == "quarterly" && (Sys.Date()-1)-90 < 
as.Date("2015-09-02") ) {
-      return(valueBox(subtitle = "User engagement", color = "black", value = 
"NA"))
+    if (date_range == "all") {
+      return(valueBox(subtitle = "User engagement", value = "N/A", color = 
"black"))
     }
-    #=========================================================================
     x <- polloi::subset_by_date_range(augmented_clickthroughs, from = 
start_date(date_range), to = Sys.Date() - 1)
     if (date_range == "quarterly") {
       return(valueBox(subtitle = "User engagement", color = "orange",
@@ -554,9 +564,17 @@
     smooth_level <- input$smoothing_kpi_load_time
     date_range <- input$kpi_summary_date_range_selector
     start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector,
-                                      daily = 1, weekly = 8, monthly = 31, 
quarterly = 91)
+                                      all = NA, daily = 1, weekly = 8, monthly 
= 31, quarterly = 91)
     load_times <- list(desktop_load_data, mobile_load_data, android_load_data, 
ios_load_data) %>%
-      lapply(polloi::subset_by_date_range, from = start_date, to = Sys.Date() 
- 1) %>%
+      {
+        if (is.na(start_date)) {
+          lapply(., function(dataset) {
+            return(dataset[!duplicated(dataset$date, dataset$event_type, 
fromLast = TRUE), ])
+          })
+        } else {
+          lapply(., polloi::subset_by_date_range, from = start_date, to = 
Sys.Date() - 1)
+        }
+      } %>%
       lapply(function(data_tail) return(data_tail[, c('date', 'Median')])) %>%
       { names(.) <- c("Desktop", "Mobile Web", "Android", "iOS"); . } %>%
       dplyr::bind_rows(.id = "Platform") %>%
@@ -582,9 +600,15 @@
   })
   output$kpi_zero_results_series <- renderDygraph({
     smooth_level <- input$smoothing_kpi_zero_results
-    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
daily = 1, weekly = 8, monthly = 31, quarterly = 91)
+    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
all = NA, daily = 1, weekly = 8, monthly = 31, quarterly = 91)
     zrr <- failure_data_with_automata %>%
-      polloi::subset_by_date_range(from = start_date, to = Sys.Date()) %>%
+      {
+        if (is.na(start_date)) {
+          .
+        } else {
+          polloi::subset_by_date_range(., from = start_date, to = Sys.Date())
+        }
+      } %>%
       transform(`Rate` = rate)
     zrr_change <- 100 * (zrr$Rate[2:nrow(zrr)] - 
zrr$Rate[1:(nrow(zrr)-1)])/zrr$Rate[1:(nrow(zrr)-1)]
     zrr <- cbind(zrr[, c('date', 'Rate')], Change = c(NA, zrr_change)) %>%
@@ -619,9 +643,17 @@
   })
   output$kpi_api_usage_series <- renderDygraph({
     smooth_level <- input$smoothing_kpi_api_usage
-    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
daily = 1, weekly = 8, monthly = 31, quarterly = 91)
+    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
all = NA, daily = 1, weekly = 8, monthly = 31, quarterly = 91)
     api_usage <- split_dataset %>%
-      lapply(polloi::subset_by_date_range, from = start_date, to = Sys.Date() 
- 1) %>%
+      {
+        if (is.na(start_date)) {
+          lapply(., function(dataset) {
+            return(dataset[!duplicated(dataset$date, dataset$event_type, 
fromLast = TRUE), ])
+          })
+        } else {
+          lapply(., polloi::subset_by_date_range, from = start_date, to = 
Sys.Date() - 1)
+        }
+      } %>%
       dplyr::bind_rows() %>%
       tidyr::spread("event_type", "events") %>%
       as.data.frame
@@ -670,9 +702,15 @@
              dyRangeSelector)
   })
   output$kpi_augmented_clickthroughs_series <- renderDygraph({
-    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
daily = 1, weekly = 8, monthly = 31, quarterly = 91)
+    start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
all = NA, daily = 1, weekly = 8, monthly = 31, quarterly = 91)
     smoothed_data <- augmented_clickthroughs %>%
-      polloi::subset_by_date_range(from = start_date, to = Sys.Date() - 1) %>%
+      {
+        if (is.na(start_date)) {
+          .
+        } else {
+          polloi::subset_by_date_range(., from = start_date, to = Sys.Date())
+        }
+      } %>%
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, 
input$smoothing_augmented_clickthroughs))
     polloi::make_dygraph(data = smoothed_data, xlab = "Date", ylab = "Rates", 
"User engagement (augmented clickthroughs) by day") %>%
       dySeries(name = colnames(smoothed_data)[2], strokeWidth = 1.5, 
strokePattern = "dashed") %>%
diff --git a/tab_documentation/kpis_summary.md 
b/tab_documentation/kpis_summary.md
index 8a8c9a5..cb5fbd5 100644
--- a/tab_documentation/kpis_summary.md
+++ b/tab_documentation/kpis_summary.md
@@ -4,7 +4,7 @@
 - **User-perceived load time** If our search is fast and snappy, then more 
people will use it! 
 - **Zero Results Rate** If a user gets zero results for their query, they’ve 
by definition not found what they’re looking for.
 - **API usage** We want people, both within our movement and outside it, to be 
able to easily access our information.
-- **User Engagement** (not quite **[User 
Satisfaction](https://meta.wikimedia.org/wiki/Research:Measuring_User_Search_Satisfaction)**)
 This is an augmented version of clickthrough rate. In it we are including the 
proportion of users' sessions exceeding a pre-specified threshold. **Note** 
that we deployed v2.0 of the satisfaction schema on 9/2/2015. You may see 
**NA** if we do not have enough data available at the time.
+- **User Engagement** (not quite **[User 
Satisfaction](https://meta.wikimedia.org/wiki/Research:Measuring_User_Search_Satisfaction)**)
 This is an augmented version of clickthrough rate. In it we are including the 
proportion of users' sessions exceeding a pre-specified threshold. **Note** 
that we deployed v2.0 of the satisfaction schema on 9/2/2015.
 
 Additional information
 ------
diff --git a/ui.R b/ui.R
index 1d951a2..5856220 100644
--- a/ui.R
+++ b/ui.R
@@ -29,7 +29,8 @@
                            div(selectInput("kpi_summary_date_range_selector",
                                            label = "KPI data range", multiple 
= FALSE, selected = "monthly",
                                            choices = list("Yesterday" = 
"daily", "Last 7 days" = "weekly",
-                                                          "Last 30 days" = 
"monthly", "Last 90 days" = "quarterly")),
+                                                          "Last 30 days" = 
"monthly", "Last 90 days" = "quarterly",
+                                                          "All available data" 
= "all")),
                                style = "margin-bottom:-10px;"),
                            menuSubItem(text = "Summary", tabName = 
"kpis_summary"),
                            menuSubItem(text = "Monthly Metrics", tabName = 
"monthly_metrics"),

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I168ade47e60cd11be175eb1527f2752197361297
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/rainbow
Gerrit-Branch: master
Gerrit-Owner: Bearloga <mpo...@wikimedia.org>
Gerrit-Reviewer: Chelsyx <c...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to