Skip to content

Commit

Permalink
second changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Sep 9, 2024
1 parent e593045 commit 5e59002
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ async def pvt_title_url_org(self, id: str) -> tuple[str, str, str]:

async def commits_across_branches(
self,
user_token: str,
*,
organization: str = "uf-mil-electrical",
) -> list[dict[str, Any]]:
Expand Down Expand Up @@ -347,6 +348,7 @@ async def commits_across_branches(
"https://api.github.com/graphql",
method="POST",
data=json.dumps({"query": query}),
user_access_token=user_token,
)
commits = []
login = properties["data"]["viewer"]["login"]
Expand Down
25 changes: 19 additions & 6 deletions src/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,13 @@ async def refresh_sheet(self) -> None:
async with self.bot.db_factory() as db:
for member in await db.authenticated_members():
token = str(member.access_token)
contributions = await self.bot.github.get_user_contributions(token)
try:
contributions = await self.bot.github.get_user_contributions(token)
except Exception:
logger.exception(
f"Error fetching contributions for {member.discord_id}",
)
continue
try:
discord_member = await self.bot.get_or_fetch_member(
member.discord_id,
Expand Down Expand Up @@ -935,11 +941,18 @@ async def refresh_sheet(self) -> None:
self._format_commit_str(payload)
for payload in contributions.commits
]
if contributions.commits and is_electrical_member:
summaries["Commits"] = [
self._format_commit_str_from_all_branches(payload)
for payload in await self.bot.github.commits_across_branches()
]
if is_electrical_member:
try:
commits = await self.bot.github.commits_across_branches(token)
if commits:
summaries["Commits"] = [
self._format_commit_str_from_all_branches(payload)
for payload in commits
]
except Exception:
logger.exception(
f"Error fetching commits across branches for user {member.discord_id}",
)
summary_str = "\n\n".join(
f"**{k}**:\n" + "\n".join(v) for k, v in summaries.items()
)
Expand Down
2 changes: 1 addition & 1 deletion src/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def parse_embed_field(
id = re.findall(r"<@!?(\d+)>", mention_str)
swimming = "(swimming)" in mention_str
if id:
member = await self.bot.get_member(int(id[0]))
member = await self.bot.get_or_fetch_member(int(id[0]))
members.append(TestingMember(member, swimming))
return members

Expand Down

0 comments on commit 5e59002

Please sign in to comment.