Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added github token #8

Merged
merged 5 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions app.py

This file was deleted.

13 changes: 10 additions & 3 deletions src/sammich/plugins/contributors.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import os

import requests
from dotenv import load_dotenv
from machine.plugins.base import MachineBasePlugin
from machine.plugins.decorators import command

load_dotenv()

GITHUB_API_URL = "https://api.github.com"
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")


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

Expand Down