-
Notifications
You must be signed in to change notification settings - Fork 0
alerts manager of inactivity #112
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,23 +1,24 @@ | ||||||
| import logging | ||||||
| import os | ||||||
| import re | ||||||
| import time | ||||||
| from datetime import datetime, timezone | ||||||
| from functools import wraps | ||||||
|
|
||||||
| import requests | ||||||
| import re | ||||||
| import schedule | ||||||
| from dotenv import load_dotenv | ||||||
|
|
||||||
| from config import load_config | ||||||
| from constants import PRIORITY_TO_SCORE | ||||||
| from github import ( | ||||||
| get_pr_diff, | ||||||
| get_prs_waiting_for_review_by_reviewer, | ||||||
| get_prs_with_changes_requested_by_reviewer, | ||||||
| get_pr_diff, | ||||||
| ) | ||||||
| from linear.issues import ( | ||||||
| get_completed_issues, | ||||||
| get_completed_issues_for_person, | ||||||
| get_open_issues, | ||||||
| get_stale_issues_by_assignee, | ||||||
| ) | ||||||
|
|
@@ -31,9 +32,18 @@ def post_to_slack(markdown: str): | |||||
| """Send a message to Slack and raise or log on failure.""" | ||||||
| url = os.environ["SLACK_WEBHOOK_URL"] | ||||||
| response = requests.post(url, json={"text": markdown}) | ||||||
| if response.status_code != 200: | ||||||
| logging.error("Slack API returned %s: %s", response.status_code, response.text) | ||||||
| response.raise_for_status() | ||||||
|
|
||||||
|
|
||||||
| def post_to_manager_slack(markdown: str): | ||||||
| """Send a message to the manager Slack webhook and raise or log on failure.""" | ||||||
| url = os.environ["MANAGER_SLACK_WEBHOOK_URL"] | ||||||
| response = requests.post(url, json={"text": markdown}) | ||||||
| if response.status_code != 200: | ||||||
| logging.error( | ||||||
| "Slack API returned %s: %s", response.status_code, response.text | ||||||
| "Manager Slack API returned %s: %s", response.status_code, response.text | ||||||
| ) | ||||||
| response.raise_for_status() | ||||||
|
|
||||||
|
|
@@ -52,7 +62,7 @@ def format_bug_line(bug): | |||||
| f"(+{bug['daysOpen']}d{platform_text}{reviewer_text})" | ||||||
| ) | ||||||
| if bug.get("priority") == 1: | ||||||
| return f"- \U0001F6A8 {content} \U0001F6A8" | ||||||
| return f"- \U0001f6a8 {content} \U0001f6a8" | ||||||
| return f"- {content}" | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -112,14 +122,8 @@ def post_priority_bugs(): | |||||
| # Urgent bugs are due after one day. Mark them at risk immediately and | ||||||
| # overdue if not fixed within a day. High priority bugs retain the | ||||||
| # existing week-long window. | ||||||
| at_risk = [ | ||||||
| bug | ||||||
| for bug in urgent_bugs | ||||||
| if bug["daysOpen"] <= 1 | ||||||
| ] + [ | ||||||
| bug | ||||||
| for bug in high_bugs | ||||||
| if bug["daysOpen"] > 4 and bug["daysOpen"] <= 7 | ||||||
| at_risk = [bug for bug in urgent_bugs if bug["daysOpen"] <= 1] + [ | ||||||
| bug for bug in high_bugs if bug["daysOpen"] > 4 and bug["daysOpen"] <= 7 | ||||||
| ] | ||||||
| overdue = [bug for bug in urgent_bugs if bug["daysOpen"] > 1] + [ | ||||||
| bug for bug in high_bugs if bug["daysOpen"] > 7 | ||||||
|
|
@@ -219,7 +223,9 @@ def post_leaderboard(): | |||||
| slack_markdown = get_slack_markdown_by_linear_username(assignee) | ||||||
| markdown += f"{medals[i]} {slack_markdown}: {score}\n" | ||||||
| markdown += "\n\n" | ||||||
| markdown += "_scores - 20pts for urgent, 10pts for high, 5pts for medium, 1pt for low_\n\n" | ||||||
| markdown += ( | ||||||
| "_scores - 20pts for urgent, 10pts for high, 5pts for medium, 1pt for low_\n\n" | ||||||
| ) | ||||||
| markdown += f"<{os.getenv('APP_URL')}?days=7|View Bug Board>" | ||||||
| post_to_slack(markdown) | ||||||
|
|
||||||
|
|
@@ -305,6 +311,32 @@ def post_stale(): | |||||
| post_to_slack(markdown) | ||||||
|
|
||||||
|
|
||||||
| @with_retries | ||||||
| def post_inactive_engineers(): | ||||||
| """Send list of engineers with no completed Linear issues in the last 7 days.""" | ||||||
| config = load_config() | ||||||
| inactive = [] | ||||||
| base_url = os.getenv("APP_URL", "") | ||||||
| for person_key, person in config.get("people", {}).items(): | ||||||
| login = person.get("linear_username") | ||||||
| if not login: | ||||||
| continue | ||||||
| try: | ||||||
| completed = get_completed_issues_for_person(login, 7) | ||||||
| except Exception as e: | ||||||
| logging.error(f"Failed to fetch completed issues for {login}: {e}") | ||||||
|
||||||
| logging.error(f"Failed to fetch completed issues for {login}: {e}") | |
| logging.error("Failed to fetch completed issues for %s: %s", login, e) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function lacks a docstring explaining its purpose and parameters. Consider adding documentation similar to the existing post_to_slack function.