Skip to content

Commit

Permalink
Don't log no contributions, update pre-commit, prevent invalid google…
Browse files Browse the repository at this point in the history
… sheets cell updates
  • Loading branch information
cbrxyz committed Sep 8, 2024
1 parent 13ed24c commit b1a0b04
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ default_language_version:

repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.27.1
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.260'
rev: 'v0.6.4'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.1
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.3.0
hooks:
- id: codespell
args:
- --ignore-words-list=nd,som,pullrequest,pullrequests
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://github.com/hadolint/hadolint
rev: v2.10.0
rev: v2.13.0-beta
hooks:
- id: hadolint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
45 changes: 39 additions & 6 deletions src/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,11 @@ async def start(self, interaction: discord.Interaction, _: discord.ui.Button):
student.report.replace("\n", "\n> ") if student.report else ""
)
await interaction.edit_original_response(
content=f"Please grade the report by **{student.name}**:\n> {report_quoted[:1900]}"
if student.report
else f"❌ **{student.name}** did not complete any activity last week.",
content=(
f"Please grade the report by **{student.name}**:\n> {report_quoted[:1900]}"
if student.report
else f"❌ **{student.name}** did not complete any activity last week."
),
view=view,
)
await view.wait()
Expand Down Expand Up @@ -663,9 +665,11 @@ async def callback(self, interaction: discord.Interaction):
id = self._task_id
while not access_token and datetime.datetime.now() < expires_in_dt:
await asyncio.sleep(
resp["interval"]
if "interval" in resp
else device_code_response["interval"],
(
resp["interval"]
if "interval" in resp
else device_code_response["interval"]
),
)
# Only use the latest response, otherwise we are going to get continuous slow_down responses
if id != self._task_id:
Expand Down Expand Up @@ -926,6 +930,11 @@ async def refresh_sheet(self) -> None:
continue
id_cell = await main_worksheet.find(discord_member.name)
a1_notation = gspread.utils.rowcol_to_a1(id_cell.row, week.report_column) # type: ignore
summary_str = summary_str.strip()
# Just in case, google sheets cells are limited to 50,000 characters
summary_str = summary_str[:50000]
if not summary_str:
continue
await main_worksheet.update(
a1_notation,
[
Expand Down Expand Up @@ -1011,8 +1020,20 @@ async def first_individual_reminder(self):
datetime.date.today(),
datetime.time(23, 59, 59),
)
async with self.bot.db_factory() as db:
authenticated_discord_users = {
user.discord_id for user in await db.authenticated_members()
}
for student in students:
if student.member:
if student.member.id not in authenticated_discord_users:
await student.member.send(
f"Hey **{student.first_name}**! It's your friendly uf-mil-bot here. I noticed you haven't connected your GitHub account yet. GitHub is a platform that your team uses to track progress of tasks. Please remember that at least one contribution to GitHub is required each week. This week's contribution is due in **twelve hours.** If you have questions about this, please see the {self.bot.member_services_channel.mention} channel or message your team lead. Thank you!",
)
logger.info(
f"Sent first individual reminder (to join GitHub) to {student.member}.",
)
continue
try:
await student.member.send(
f"Hey **{student.first_name}**! It's your friendly uf-mil-bot here. I noticed you haven't provided a contribution or status update through GitHub this week. Please create it by {discord.utils.format_dt(deadline_tonight, 't')} tonight. Thank you!",
Expand All @@ -1033,8 +1054,20 @@ async def second_individual_reminder(self):
datetime.date.today(),
datetime.time(23, 59, 59),
)
async with self.bot.db_factory() as db:
authenticated_discord_users = {
user.discord_id for user in await db.authenticated_members()
}
for student in students:
if student.member:
if student.member.id not in authenticated_discord_users:
await student.member.send(
f"Hey **{student.first_name}**! It's your friendly uf-mil-bot here. I noticed you haven't connected your GitHub account yet. GitHub is a platform that your team uses to track progress of tasks. Please remember that at least one contribution to GitHub is required each week. This week's contribution is due in **four hours.** If you have questions about this, please see the {self.bot.member_services_channel.mention} channel or message your team lead. Thank you!",
)
logger.info(
f"Sent second individual reminder (to join GitHub) to {student.member}.",
)
continue
try:
await student.member.send(
f"Hey **{student.first_name}**! It's your friendly uf-mil-bot here again. I noticed you haven't created your contribution or status update for this week yet. There are only **four hours** remaining to create your contribution! Please submit it through GitHub by {discord.utils.format_dt(deadline_tonight, 't')} tonight. Thank you!",
Expand Down

0 comments on commit b1a0b04

Please sign in to comment.