Spaces:
Sleeping
Sleeping
Update scheduler.py
Browse files- scheduler.py +22 -2
scheduler.py
CHANGED
|
@@ -31,6 +31,7 @@ def _today() -> str:
|
|
| 31 |
|
| 32 |
|
| 33 |
def _get_current_day(candidate: dict) -> int:
|
|
|
|
| 34 |
stage = candidate["stage"]
|
| 35 |
if stage == "week0":
|
| 36 |
start = candidate.get("week0_start_date", "")
|
|
@@ -38,8 +39,18 @@ def _get_current_day(candidate: dict) -> int:
|
|
| 38 |
start = candidate.get("probation_start_date", "")
|
| 39 |
if not start:
|
| 40 |
return 1
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -146,8 +157,15 @@ FT_DAILY_BRIEFS = {
|
|
| 146 |
}
|
| 147 |
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
def job_morning_ft_brief() -> None:
|
| 150 |
"""Send FT the day's focus brief at 9:00 AM."""
|
|
|
|
| 151 |
active = sheets.get_active_candidates()
|
| 152 |
for candidate in active:
|
| 153 |
stage = candidate["stage"]
|
|
@@ -168,6 +186,7 @@ def job_morning_ft_brief() -> None:
|
|
| 168 |
|
| 169 |
def job_missed_report_check() -> None:
|
| 170 |
"""Check for missed reports 30 min after each window closes."""
|
|
|
|
| 171 |
handlers.handle_missed_report_check()
|
| 172 |
|
| 173 |
|
|
@@ -192,6 +211,7 @@ FT_SIGNAL_QUESTIONS = {
|
|
| 192 |
|
| 193 |
def job_eod_signal_questions() -> None:
|
| 194 |
"""Send FT the signal question for today at 6:00 PM."""
|
|
|
|
| 195 |
active = sheets.get_active_candidates()
|
| 196 |
for candidate in active:
|
| 197 |
stage = candidate["stage"]
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
def _get_current_day(candidate: dict) -> int:
|
| 34 |
+
"""Count working days (Mon-Sat) since start date. Sundays skipped."""
|
| 35 |
stage = candidate["stage"]
|
| 36 |
if stage == "week0":
|
| 37 |
start = candidate.get("week0_start_date", "")
|
|
|
|
| 39 |
start = candidate.get("probation_start_date", "")
|
| 40 |
if not start:
|
| 41 |
return 1
|
| 42 |
+
start_date = date.fromisoformat(start)
|
| 43 |
+
today = date.today()
|
| 44 |
+
working_days = 0
|
| 45 |
+
current = start_date
|
| 46 |
+
while current <= today:
|
| 47 |
+
if current.weekday() != 6: # skip Sundays
|
| 48 |
+
working_days += 1
|
| 49 |
+
current = current.replace(day=current.day + 1) if current.day < 28 else (
|
| 50 |
+
current.replace(month=current.month + 1, day=1) if current.month < 12
|
| 51 |
+
else current.replace(year=current.year + 1, month=1, day=1)
|
| 52 |
+
)
|
| 53 |
+
return max(1, working_days)
|
| 54 |
|
| 55 |
|
| 56 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 157 |
}
|
| 158 |
|
| 159 |
|
| 160 |
+
|
| 161 |
+
def _is_working_day() -> bool:
|
| 162 |
+
"""Returns False on Sundays β no reports expected, no warnings fired."""
|
| 163 |
+
return date.today().weekday() != 6 # 6 = Sunday
|
| 164 |
+
|
| 165 |
+
|
| 166 |
def job_morning_ft_brief() -> None:
|
| 167 |
"""Send FT the day's focus brief at 9:00 AM."""
|
| 168 |
+
if not _is_working_day(): return
|
| 169 |
active = sheets.get_active_candidates()
|
| 170 |
for candidate in active:
|
| 171 |
stage = candidate["stage"]
|
|
|
|
| 186 |
|
| 187 |
def job_missed_report_check() -> None:
|
| 188 |
"""Check for missed reports 30 min after each window closes."""
|
| 189 |
+
if not _is_working_day(): return
|
| 190 |
handlers.handle_missed_report_check()
|
| 191 |
|
| 192 |
|
|
|
|
| 211 |
|
| 212 |
def job_eod_signal_questions() -> None:
|
| 213 |
"""Send FT the signal question for today at 6:00 PM."""
|
| 214 |
+
if not _is_working_day(): return
|
| 215 |
active = sheets.get_active_candidates()
|
| 216 |
for candidate in active:
|
| 217 |
stage = candidate["stage"]
|