Skip to content
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
18 changes: 15 additions & 3 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import re
import time
from datetime import datetime, timezone
from datetime import date, datetime, timezone
from urllib.parse import urlsplit, urlunsplit

import requests
Expand Down Expand Up @@ -69,6 +69,10 @@ def _is_inactive_project(project: dict) -> bool:
return bool(project.get("completedAt")) or status_name in INACTIVE_PROJECT_STATUS_NAMES


def _format_short_weekday(project_date: date) -> str:
return project_date.strftime("%a")


def _normalize_linear_display_name(name: str) -> str:
return name.replace(".", " ").replace("-", " ").title()

Expand Down Expand Up @@ -655,7 +659,12 @@ def post_project_updates():
target_dt = parse_iso_date(project.get("targetDate"))
days_left, target_status_text = format_project_target_status(target_dt, now=now)
if not inactive and target_dt and target_status_text:
line = f"- <{url}|{name}> - {target_status_text} - Lead: {lead_md}"
target_label = (
target_status_text
if target_status_text.endswith("overdue")
else _format_short_weekday(target_dt)
)
line = f"- <{url}|{name}> - {target_label} - Lead: {lead_md}"
if target_status_text.endswith("overdue"):
overdue.append({"name": name, "target_dt": target_dt, "line": line})
elif days_left is not None and 0 <= days_left <= 3:
Expand All @@ -671,7 +680,10 @@ def post_project_updates():
{
"name": name,
"start_dt": start_dt,
"line": f"- <{url}|{name}> - Lead: {lead_md}",
"line": (
f"- <{url}|{name}> - {_format_short_weekday(start_dt)} "
f"- Lead: {lead_md}"
),
}
)

Expand Down
14 changes: 14 additions & 0 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,20 @@ def test_groups_overdue_ending_soon_and_starting_soon_in_order(self):
self.assertIn("Starting Tue", message)
self.assertIn("Starting Wed", message)
self.assertIn("Lead: <@U1>", message)
self.assertIn(
"- <https://linear.app/project/ending-tue|Ending Tue> - Tue - Lead: <@U1>", message
)
self.assertIn(
"- <https://linear.app/project/ending-wed|Ending Wed> - Wed - Lead: <@U1>", message
)
self.assertIn(
"- <https://linear.app/project/starting-tue|Starting Tue> - Tue - Lead: <@U1>", message
)
self.assertIn(
"- <https://linear.app/project/starting-wed|Starting Wed> - Wed - Lead: <@U1>", message
)
self.assertNotIn("d left", message)
self.assertNotIn("h left", message)

# Correct projects filtered out
self.assertNotIn("Ending Far", message)
Expand Down
Loading