Last active
March 30, 2022 21:23
-
-
Save dudanogueira/19df34cce4744777c842b9950778e99c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, urllib, datetime, os | |
from github import Github | |
g = Github(os.environ.get("GH_TOKEN")) | |
repo_rc = g.get_repo("RocketChat/Rocket.Chat") | |
repo_fq = g.get_repo("RocketChat/feature-requests") | |
opened_per_year = {} | |
closed_per_year = {} | |
open_close_same_year = {} | |
# issues created and opened on the same year | |
for issue in repo_rc.get_issues(state="all"): | |
item = issue | |
print("ISSUE #" + str(item.number) + ": " + item.title) | |
if item.created_at.year not in opened_per_year: | |
opened_per_year[item.created_at.year] = 0 | |
opened_per_year[item.created_at.year] += 1 | |
if item.closed_at: | |
if item.closed_at.year not in closed_per_year: | |
closed_per_year[item.closed_at.year] = 0 | |
closed_per_year[item.closed_at.year] += 1 | |
if item.created_at.year == item.closed_at.year: | |
if item.created_at.year not in open_close_same_year: | |
open_close_same_year[item.created_at.year] = 0 | |
open_close_same_year[item.created_at.year] += 1 | |
print("issue year,opened,closed,same year") | |
for i in opened_per_year.keys(): | |
line = "{0},{1},{2},{3}".format( | |
i, opened_per_year[i], | |
closed_per_year[i], open_close_same_year[i] | |
) | |
print(line) | |
# | |
# PR | |
# | |
# pr created and opened on the same year | |
opened_per_year = {} | |
opened_per_year_core_team = {} | |
closed_per_year = {} | |
open_close_same_year = {} | |
# issues created and opened on the same year | |
for pr in repo_rc.get_pulls(state="all"): | |
item = pr | |
print("PR #" + str(item.number) + ": " + item.title) | |
if item.user.company == "Rocket.Chat": | |
if item.created_at.year not in opened_per_year_core_team: | |
opened_per_year_core_team[item.created_at.year] = 0 | |
opened_per_year_core_team[item.created_at.year] += 1 | |
if item.created_at.year not in opened_per_year: | |
opened_per_year[item.created_at.year] = 0 | |
opened_per_year[item.created_at.year] += 1 | |
if item.closed_at: | |
if item.closed_at.year not in closed_per_year: | |
closed_per_year[item.closed_at.year] = 0 | |
closed_per_year[item.closed_at.year] += 1 | |
if item.created_at.year == item.closed_at.year: | |
if item.created_at.year not in open_close_same_year: | |
open_close_same_year[item.created_at.year] = 0 | |
open_close_same_year[item.created_at.year] += 1 | |
print("pr year,opened,closed,same year") | |
for i in opened_per_year.keys(): | |
line = "{0},{1},{2},{3}".format( | |
i, opened_per_year[i], | |
closed_per_year[i], open_close_same_year[i] | |
) | |
print(line) | |
print(''' | |
INSTRUCTIONS: | |
paste the contents below on the Community Metric Sheet, on it's corresponding tab | |
press: alt+d+e in order to split lines into columns | |
''') | |
print("#"*10) | |
print("#"*10) | |
print("#"*10) | |
issues = repo_rc.get_issues(labels=[repo_rc.get_label("duplicate")], state="all") | |
print("TAB DupClosed: {0}".format(issues.totalCount)) | |
for i in issues: | |
reference_date = i.created_at | |
print("{0}-{1},{2}".format(reference_date.year, reference_date.month, i.html_url)) | |
print("#"*10) | |
print("#"*10) | |
print("#"*10) | |
issues = repo_rc.get_issues(state="all", sort="created") | |
print("TAB TaggedTriaged: {0}".format(issues.totalCount)) | |
for i in issues: | |
if i.labels: | |
reference_date = i.created_at | |
print("{0}-{1},{2}".format(reference_date.year, reference_date.month, i.html_url)) | |
r = requests.get("https://api.github.com/repos/RocketChat/feature-requests/issues?labels=stat%3A%20issue2feature") | |
print("#"*10) | |
print("#"*10) | |
print("#"*10) | |
print("TAB Issues2Feature: {0}".format(len(r.json()))) | |
for i in r.json(): | |
reference_date = i["created_at"] | |
date = datetime.datetime.strptime(reference_date, "%Y-%m-%dT%H:%M:%SZ") | |
print("{0}-{1},{2}".format(date.year, date.month, i["html_url"])) | |
# | |
# TAG AS BUG | |
# | |
print("#"*10) | |
print("#"*10) | |
print("#"*10) | |
issues = repo_rc.get_issues(labels=[repo_rc.get_label("bug")]) | |
print("TAB VerifiedBug: {0}".format(issues.totalCount)) | |
for i in issues: | |
reference_date = i.created_at | |
print("{0}-{1},{2}".format(reference_date.year, reference_date.month, i.html_url)) | |
# | |
# TOTAL OPEN FEATURE REQUESTS | |
# | |
q = "RocketChat feature-requests is:open is:issue" | |
qq = urllib.parse.quote(q) | |
r = requests.get("https://api.github.com/search/issues?q={0}".format(qq)) | |
print("#"*10) | |
print("#"*10) | |
print("#"*10) | |
print("TAB FeaturesRequestOpen: {0}".format(r.json()["total_count"])) | |
for i in r.json()["items"]: | |
reference_date = i["created_at"] | |
date = datetime.datetime.strptime(reference_date, "%Y-%m-%dT%H:%M:%SZ") | |
print("{0}-{1},{2}".format(date.year, date.month, i["html_url"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment