From 9b2eaf9fe21a1fb093329b2e8f0276ed327fdb87 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 30 Jun 2023 23:20:52 +0000 Subject: [PATCH] commit time metrics --- .gitignore | 1 + commits/commits.py | 26 ++++++++++++++++++++++++++ commits/commits2.py | 28 ++++++++++++++++++++++++++++ metrics/Dockerfile | 2 +- metrics/render.py | 1 - 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 commits/commits.py create mode 100644 commits/commits2.py diff --git a/.gitignore b/.gitignore index 4a9a9ef..97cb2af 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,4 @@ cython_debug/ #.idea/ *.png +commits.json diff --git a/commits/commits.py b/commits/commits.py new file mode 100644 index 0000000..d7ea30a --- /dev/null +++ b/commits/commits.py @@ -0,0 +1,26 @@ +import asyncio +import json + +import aiohttp + + +async def main(): + pages = [] + async with aiohttp.ClientSession() as session: + i = 1 + while True: + async with session.get( + f"https://gitea.parrrate.ru/api/v1/repos/PTV/radn-rs/commits?stat=true&page={i}", + headers={"accept": "application/json"}, + ) as response: + page = await response.json() + if not page: + break + pages.extend(page) + print(i) + i += 1 + with open("commits.json", "w") as file: + json.dump(pages, file, indent=2) + + +asyncio.run(main()) diff --git a/commits/commits2.py b/commits/commits2.py new file mode 100644 index 0000000..f01aea9 --- /dev/null +++ b/commits/commits2.py @@ -0,0 +1,28 @@ +import json +from datetime import datetime +from itertools import pairwise + +import matplotlib.pyplot as plt +import numpy as np + +plt.rcParams["figure.figsize"] = [18, 9] +plt.style.use("dark_background") +plt.subplots_adjust(left=0.05, right=0.99, top=0.95, bottom=0.05) + +with open("commits.json", "r") as file: + pages = json.load(file) +times = [] +for commit in pages: + times.append(datetime.strptime(commit["created"], "%Y-%m-%dT%H:%M:%SZ")) +deltas = [] +for a, b in pairwise(times): + deltas.append((a - b)) +deltas.sort() +print("start") +for delta in deltas: + print(delta) +X = np.arange(len(deltas)) +Y = np.array([delta.total_seconds() for delta in deltas]) +plt.gca().set_yscale("log") +plt.scatter(X, Y, s=2.0) +plt.savefig("commits.png") diff --git a/metrics/Dockerfile b/metrics/Dockerfile index 194ab7f..ca4d167 100644 --- a/metrics/Dockerfile +++ b/metrics/Dockerfile @@ -3,7 +3,7 @@ RUN cargo install rust-code-analysis-cli WORKDIR /code/ RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git WORKDIR /code/radn-rs/ -RUN git fetch && git checkout de26092abcc44fa249bbbfd0309613783107af52 +RUN git fetch && git checkout 540fdce02aefcb0dae5735c55daec690c4571b18 COPY metrics.py /code/metrics.py RUN python3 /code/metrics.py FROM python:3.11 diff --git a/metrics/render.py b/metrics/render.py index 948f5d9..05b5fe9 100644 --- a/metrics/render.py +++ b/metrics/render.py @@ -1,4 +1,3 @@ -import gc import json import matplotlib.pyplot as plt