diff --git a/src/github_api.py b/src/github_api.py index 753947f..6b7c819 100644 --- a/src/github_api.py +++ b/src/github_api.py @@ -1,13 +1,11 @@ # Marakulin Andrey https://github.com/Annndruha # 2023 -import logging import requests class Github: def __init__(self, organization_nickname, token): - self.organization_nickname = organization_nickname self.issue_url = 'https://api.github.com/repos/' + organization_nickname + '/{}/issues' self.graphql_url = 'https://api.github.com/graphql' self.org_repos_url = f'https://api.github.com/orgs/{organization_nickname}/repos' @@ -21,7 +19,7 @@ def __init__(self, organization_nickname, token): } def open_issue(self, repo, title, comment): - payload = {'title': title, 'body': comment, 'projects': f'{self.organization_nickname}/7'} + payload = {'title': title, 'body': comment} r = requests.post(self.issue_url.format(repo), headers=self.headers, json=payload) if 'Issues are disabled for this repo' in r.text: raise GithubIssueDisabledError @@ -64,34 +62,6 @@ def set_assignee(self, repo, number_str, member_login, comment): r = requests.patch(url, headers=self.headers, json=payload) return r - def add_to_scrum(self, node_id): - try: - PROJECT_ID = 'PVT_kwDOBaPiZM4AFiz-' - add_item_to_scrum = {'query': 'mutation{ addProjectV2ItemById(input: {projectId: "%s" contentId: "%s"}) { ' - 'item { id } } }' % (PROJECT_ID, node_id)} - r = requests.post(url=self.graphql_url, json=add_item_to_scrum, headers=self.headers) - - if 'errors' not in r.json(): - logging.info(f'Node {node_id} successfully added to scrum Твой ФФ!') - else: - logging.warning(f'Node {node_id} not added to scrum. Reason: {r.json()["errors"]}') - - FIELD_ID = 'PVTSSF_lADOBaPiZM4AFiz-zgDMeOc' - BACKLOG_OPTION_ID = '4a4a1bb5' - set_item_status_to_scrum = {'query': 'mutation {updateProjectV2ItemFieldValue(input: ' - '{projectId: "%s", itemId: "%s", fieldId: ' - '"%s",value: {singleSelectOptionId: "%s"}}) ' - '{projectV2Item{id}}}' % (PROJECT_ID, node_id, - FIELD_ID, BACKLOG_OPTION_ID)} - - r = requests.post(url=self.graphql_url, json=set_item_status_to_scrum, headers=self.headers) - if 'errors' not in r.json(): - logging.info(f'Node {node_id} successfully set backlog status.') - else: - logging.warning(f'Node {node_id} not set status. Reason: {r.json()["errors"]}') - except Exception as err: - logging.error(f'Scrum adding FAILED: {err.args}') - class GithubIssueDisabledError(Exception): pass diff --git a/src/handlers.py b/src/handlers.py index e5c32ea..02acc7d 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -193,8 +193,6 @@ async def __create_issue(update: Update, context: ContextTypes.DEFAULT_TYPE): logging.info(f'[{update.callback_query.from_user.id} {update.callback_query.from_user.full_name}]' f'[{update.callback_query.message.id}] Succeeded open Issue: {response["html_url"]}') - github.add_to_scrum(response['node_id']) - else: await context.bot.answer_callback_query(update.callback_query.id, f'Response code: {r.status_code}') text = __join_to_message_text(title, 'No repo', assigned, comment, '⚠️')