1
0
mw-lifecycle-analysis/ww-task-plot-script.R
2025-05-24 16:59:03 -07:00

99 lines
4.7 KiB
R

library(tidyverse)
c1_count <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/phab_tasks.csv"
c1_input_df <- read.csv(c1_count , header = TRUE)
c2_count <- "/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case2/phab_tasks.csv"
c2_input_df <- read.csv(c2_count , header = TRUE)
c3_count <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case3/phab_tasks.csv"
c3_input_df <- read.csv(c3_count , header = TRUE)
c1_unique_counts <- c1_input_df %>%
group_by(meta.affil, week_bin) %>%
summarise(unique_count = n_distinct(conversation_id), .groups = "drop")
c2_unique_counts <- c2_input_df %>%
group_by(meta.affil, week_bin) %>%
summarise(unique_count = n_distinct(conversation_id), .groups = "drop")
c3_unique_counts <- c3_input_df %>%
group_by(meta.affil, week_bin) %>%
summarise(unique_count = n_distinct(conversation_id), .groups = "drop")
c1_unique_counts <- c1_unique_counts%>% mutate(source = "c1")
c2_unique_counts <- c2_unique_counts %>% mutate(source = "c2")
c3_unique_counts <- c3_unique_counts %>% mutate(source = "c3")
combined_df <- bind_rows(c1_unique_counts, c2_unique_counts, c3_unique_counts)
library(scales)
library(ggplot2)
affiliationColors <-
setNames( c('#5da2d8', '#c7756a')
,c("False", "True"))
commit_authors <- combined_df |>
ggplot(aes(x=week_bin,
y=unique_count,
fill=factor(meta.affil))) +
geom_col(position='dodge2') +
labs(x = "Relative Week", y = "New Tasks Created", fill="Task Author") +
geom_vline(data = combined_df |> filter(source == "c1"),
aes(xintercept = -29),
linetype = "dotted", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c1"),
aes(xintercept = -9),
linetype = "dotted", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c1"),
aes(xintercept = -4),
linetype = "3313", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c2"),
aes(xintercept = -99),
linetype = "dotted", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c2"),
aes(xintercept = -4),
linetype = "3313", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c3"),
aes(xintercept = -97),
linetype = "dotted", color = "black", linewidth = 0.5) +
geom_vline(data = combined_df |> filter(source == "c3"),
aes(xintercept = -3),
linetype = "3313", color = "black", linewidth = 0.5) +
geom_text(data = data.frame(source = "c1", relative_week = -39, lengthened_commit_count = 130),
aes(x = relative_week, y = lengthened_commit_count, label = "Opt-In Testing Deployment"),
inherit.aes = FALSE, color = "black", size = 4) +
geom_vline(xintercept = 0, linetype = "dashed", color = "black", linewidth = 0.5) + # Add vertical line at week 0
geom_text(data = data.frame(source = "c2", relative_week = 7, lengthened_commit_count = 130),
aes(x = relative_week, y = lengthened_commit_count, label = "Wide Deployment"),
inherit.aes = FALSE, color = "black", size = 4) +
geom_text(data = data.frame(source = "c3", relative_week = -15, lengthened_commit_count = 130),
aes(x = relative_week, y = lengthened_commit_count, label = "Wide Deployment Announcement"),
inherit.aes = FALSE, color = "black", size = 4) +
scale_fill_manual(values = affiliationColors,
labels = c("False" = "Unaffiliated",
"True" = "WMF-affiliated")) +
ggtitle("New Phabricator Tasks During Deployment Process") +
theme_bw()+
theme(
legend.position = "top",
plot.title = element_text(size = 18, face = "bold"), # Increase title font size
axis.title.x = element_text(size = 16), # Increase x-axis title font size
axis.title.y = element_text(size = 16), # Increase y-axis title font size
axis.text.x = element_text(size = 16), # Increase x-axis text font size
axis.text.y = element_text(size = 16), # Increase y-axis text font size
legend.text = element_text(size = 16), # Increase legend text font size
legend.title = element_text(size = 16),
strip.text = element_text(size = 14)# Increase legend title font size
) +
facet_wrap(~source, nrow = 3, labeller = labeller(source = c(
"c1" = "VisualEditor (2013)",
"c2" = "HTTPS-as-default (2013)",
"c3" = "HTTP-deprecation (2015)"
)))
commit_authors
ggsave(filename = "d1-m2-tasks-faceted.png", plot = commit_authors, width = 15, height = 9, dpi = 800)