Skip to content

Commit

Permalink
revise stats
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Sep 30, 2024
1 parent a15623a commit 999dcaa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
25 changes: 17 additions & 8 deletions scripts/issues_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
import pandas as pd
from github import Github

REPOSITORIES = (
"bopen/c3s-eqc-toolbox-template",
"ecmwf-projects/c3s2-eqc-quality-assessment",
)

filename = input("Insert CSV file name: ")
token = input("Insert token: ")
g = Github(login_or_token=token)
repo = g.get_repo("bopen/c3s-eqc-toolbox-template")

columns = ["number", "title", "created_at", "closed_at"]
data = {column: [] for column in columns}
for issue in repo.get_issues(state="all"):
if issue.pull_request:
continue
for column in columns:
data[column].append(getattr(issue, column))
df = pd.DataFrame.from_dict(data)
df.to_csv(filename, index=False)
data["repository"] = []
for repo_name in REPOSITORIES:
repo = g.get_repo(repo_name)
for issue in repo.get_issues(state="all"):
if issue.pull_request:
continue
data["repository"].append(repo_name)
for column in columns:
data[column].append(getattr(issue, column))
df = pd.DataFrame.from_dict(data)
df.to_csv(filename, index=False)
38 changes: 24 additions & 14 deletions scripts/notebook_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@
import datetime
import pathlib
import subprocess
import tempfile

import pandas as pd

notebook_path = input("Insert path to notebooks dir: ")
filename = input("Insert CSV file name: ")
REPOSITORIES = (
"bopen/c3s-eqc-toolbox-template",
"ecmwf-projects/c3s2-eqc-quality-assessment",
)

data = collections.defaultdict(list)
for path in pathlib.Path(notebook_path).glob("wp*/*.ipynb"):
stdout = subprocess.run(
f"git log --follow --format=%ad --date iso-strict {path.resolve()!s}",
capture_output=True,
shell=True,
text=True,
).stdout
dates = list(map(datetime.datetime.fromisoformat, stdout.splitlines()))
data["name"].append(path.stem)
data["wp"].append(path.parent.stem)
data["created_at"].append(dates[-1])
data["modified_at"].append(dates[0])
filename = input("Insert CSV file name: ")
for repository in REPOSITORIES:
with tempfile.TemporaryDirectory() as tmpdir:
subprocess.run(
["git", "clone", f"[email protected]:{repository}.git", tmpdir], check=True
)
for path in pathlib.Path(tmpdir).glob("**/*.ipynb"):
stdout = subprocess.run(
f"git log --follow --format=%ad --date iso-strict -- {path!s}",
capture_output=True,
shell=True,
text=True,
cwd=tmpdir,
).stdout
dates = list(map(datetime.datetime.fromisoformat, stdout.splitlines()))
data["name"].append(str(path.relative_to(tmpdir)))
data["repository"].append(repository)
data["created_at"].append(dates[-1])
data["modified_at"].append(dates[0])
df = pd.DataFrame.from_dict(data)
df.to_csv(filename, index=False)

0 comments on commit 999dcaa

Please sign in to comment.