|
| 1 | +import pandas as pd |
| 2 | +import numpy as np |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import datetime |
| 5 | + |
| 6 | +plt.style.use("default") |
| 7 | +plt.style.use("./cyberpunk.mplstyle") |
| 8 | + |
| 9 | +# |
| 10 | +# Load data |
| 11 | +# |
| 12 | + |
| 13 | +print("Loading data...") |
| 14 | +# https://data-analysis.fedoraproject.org/csv-reports/countme/totals.csv |
| 15 | +orig = pd.read_csv( |
| 16 | + "totals.csv", |
| 17 | + usecols=["week_end", "repo_tag", "os_variant", "hits"], |
| 18 | + parse_dates=["week_end"], |
| 19 | + # low_memory=False, |
| 20 | + dtype={ |
| 21 | + "repo_tag": "object", |
| 22 | + "os_variant": "category", |
| 23 | + }, |
| 24 | +) |
| 25 | + |
| 26 | +# # Detailed data |
| 27 | +# orig = pd.read_csv( |
| 28 | +# "totals.csv", |
| 29 | +# parse_dates=["week_start", "week_end"], |
| 30 | +# # low_memory=False, |
| 31 | +# dtype={ |
| 32 | +# "repo_tag": "object", |
| 33 | +# "repo_arch": "object", |
| 34 | +# "os_name": "category", |
| 35 | +# "os_version": "category", |
| 36 | +# "os_variant": "category", |
| 37 | +# "os_arch": "category", |
| 38 | +# }, |
| 39 | +# ) |
| 40 | + |
| 41 | +# Select repos and filter outages |
| 42 | +print("Plotting...") |
| 43 | +d = orig[ |
| 44 | + orig["repo_tag"].isin( |
| 45 | + [ |
| 46 | + *[f"fedora-{v}" for v in range(30, 45)], |
| 47 | + # *[f"fedora-cisco-openh264-{v}" for v in range(40, 41)], |
| 48 | + ] |
| 49 | + ) |
| 50 | +] |
| 51 | + |
| 52 | +d = d[ |
| 53 | + # End of year partial week |
| 54 | + (d["week_end"] != pd.to_datetime("2024-12-29")) |
| 55 | + # & (d["week_end"] != pd.to_datetime("2023-10-23")) |
| 56 | +] |
| 57 | + |
| 58 | +START_DATE = "2024-07-01" # "2021-3-1" |
| 59 | +END_DATE = datetime.datetime.now() # "2025-02-02" |
| 60 | + |
| 61 | +for fig, oss in [ |
| 62 | + ("ublue", ["Bluefin", "Bazzite", "Aurora"]), |
| 63 | + ("nonbazzite", ["Bluefin", "Aurora"]), |
| 64 | +]: |
| 65 | + plt.figure() |
| 66 | + for os in oss: |
| 67 | + mask = d["os_variant"].str.lower().str.contains(os.lower(), na=False) |
| 68 | + res = d[mask].groupby("week_end")["hits"].sum() |
| 69 | + plt.plot(res.index, res.values, label=f"{os} ({res[res.index.max()] / 1000:.1f}k)") # type: ignore |
| 70 | + # print(res) |
| 71 | + |
| 72 | + plt.title("Active Devices per Week") |
| 73 | + plt.xlabel("Week") |
| 74 | + plt.ylabel("Hits") |
| 75 | + |
| 76 | + plt.xlim([pd.to_datetime(START_DATE), pd.to_datetime(END_DATE)]) |
| 77 | + |
| 78 | + plt.xticks(rotation=45) |
| 79 | + plt.legend() |
| 80 | + plt.tight_layout() |
| 81 | + |
| 82 | + plt.savefig(f"growth_{fig}.png") |
0 commit comments