Skip to content

Commit

Permalink
Update pre-commit rules
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Jun 7, 2024
1 parent fee7055 commit 8fa0b52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
29 changes: 10 additions & 19 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@

app = Flask(__name__)

slack_events_adapter = SlackEventAdapter(
os.environ["SIGNING_SECRET"], "/slack/events", app
)
slack_events_adapter = SlackEventAdapter(os.environ["SIGNING_SECRET"], "/slack/events", app)
client = WebClient(token=os.environ["SLACK_TOKEN"])
client.chat_postMessage(
channel=DEPLOYS_CHANNEL_NAME, text="bot started v1.8 24-05-28 top"
)
client.chat_postMessage(channel=DEPLOYS_CHANNEL_NAME, text="bot started v1.8 24-05-28 top")


def fetch_github_data(owner, repo):
prs = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/pulls?state=closed"
).json()
issues = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues?state=closed"
).json()
comments = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues/comments"
).json()
prs = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/pulls?state=closed").json()
issues = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues?state=closed").json()
comments = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues/comments").json()
return prs, issues, comments


Expand All @@ -58,11 +48,12 @@ def format_data(prs, issues, comments):
user_data[user] = {"prs": 0, "issues": 0, "comments": 0}
user_data[user]["comments"] += 1

table = "User | PRs Merged | Issues Resolved | Comments\n ---- | ---------- | --------------- | --------\n"
table = (
"User | PRs Merged | Issues Resolved | Comments\n"
" ---- | ---------- | --------------- | --------\n"
)
for user, counts in user_data.items():
table += (
f"{user} | {counts['prs']} | {counts['issues']} | {counts['comments']}\n"
)
table += f"{user} | {counts['prs']} | {counts['issues']} | {counts['comments']}\n"

return table

Expand Down
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ slack-sdk = "^3.27.2"
slackeventsapi = "^3.0.1"
requests = "^2.32.3"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
known_first_party = ["lettuce", "tests"]
line_length = 99
multi_line_output = 3
profile = "black"

[tool.ruff]
line-length = 99
target-version = "py311"

[tool.ruff.lint]
select = ["E4", "E5", "E7", "E9", "F", "N"]

[tool.ruff.lint.flake8-errmsg]
max-string-length = 99
23 changes: 9 additions & 14 deletions src/sammich/plugins/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@


def fetch_github_data(owner, repo):
prs = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/pulls?state=closed"
).json()
issues = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues?state=closed"
).json()
comments = requests.get(
f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues/comments"
).json()
prs = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/pulls?state=closed").json()
issues = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues?state=closed").json()
comments = requests.get(f"{GITHUB_API_URL}/repos/{owner}/{repo}/issues/comments").json()
return prs, issues, comments


Expand Down Expand Up @@ -42,17 +36,18 @@ def format_data(prs, issues, comments):
max_name_length = max(len(user) for user in user_data.keys())
max_prs_length = max(len(str(counts["prs"])) for counts in user_data.values())
max_issues_length = max(len(str(counts["issues"])) for counts in user_data.values())
max_comments_length = max(
len(str(counts["comments"])) for counts in user_data.values()
)
max_comments_length = max(len(str(counts["comments"])) for counts in user_data.values())

table = [
f"| {'User':<{max_name_length}} | PRs Merged | Issues Resolved | Comments |",
f"|{'-' * (max_name_length + 2)}|:{'-' * (max_prs_length + 2)}:|:{'-' * (max_issues_length + 2)}:|:{'-' * (max_comments_length + 2)}:|",
f"|{'-' * (max_name_length + 2)}|:{'-' * (max_prs_length + 2)}:|"
f":{'-' * (max_issues_length + 2)}:|:{'-' * (max_comments_length + 2)}:|",
]
for user, counts in user_data.items():
table.append(
f"| {user:<{max_name_length}} | {counts['prs']:>{max_prs_length}} | {counts['issues']:>{max_issues_length}} | {counts['comments']:>{max_comments_length}} |"
f"| {user:<{max_name_length}} | {counts['prs']:>{max_prs_length}} | "
f"{counts['issues']:>{max_issues_length}} | "
f"{counts['comments']:>{max_comments_length}} |"
)

return "\n".join(table)
Expand Down

0 comments on commit 8fa0b52

Please sign in to comment.