Use four fixed daily publish slots
Some checks failed
🚀 Deploy to Hetzner / deploy (push) Has been cancelled
Backend Tests / backend-tests (push) Has been cancelled

This commit is contained in:
Oliver 2026-07-24 10:38:04 +02:00
parent 50f29cc948
commit 90646d03a6
No known key found for this signature in database
5 changed files with 17 additions and 16 deletions

View file

@ -40,9 +40,9 @@ PIPELINE_RELEVANCE_AUTO=80
# Relevanz-Score >= dieser Wert, aber < AUTO: Telegram-Warnung senden # Relevanz-Score >= dieser Wert, aber < AUTO: Telegram-Warnung senden
PIPELINE_RELEVANCE_WARN=60 PIPELINE_RELEVANCE_WARN=60
# Maximale Veröffentlichungen pro Tag innerhalb des Fensters unten # Maximale Veröffentlichungen pro Tag innerhalb des Fensters unten
PIPELINE_MAX_DRAFTS_PER_DAY=3 PIPELINE_MAX_DRAFTS_PER_DAY=4
# Bevorzugte Veröffentlichungszeiten (Stunden, kommagetrennt, Europe/Berlin) # Bevorzugte Veröffentlichungszeiten (Stunden, kommagetrennt, Europe/Berlin)
PIPELINE_PUBLISH_HOURS=9,14 PIPELINE_PUBLISH_HOURS=9,12,15,18
# Frühester/spätester Slot sowie Mindestabstand für zusätzliche Slots # Frühester/spätester Slot sowie Mindestabstand für zusätzliche Slots
PIPELINE_PUBLISH_START_HOUR=9 PIPELINE_PUBLISH_START_HOUR=9
PIPELINE_PUBLISH_END_HOUR=19 PIPELINE_PUBLISH_END_HOUR=19

View file

@ -44,8 +44,8 @@ class Settings(BaseSettings):
# Pipeline behaviour # Pipeline behaviour
pipeline_relevance_auto: int = 80 # >= this: auto-process pipeline_relevance_auto: int = 80 # >= this: auto-process
pipeline_relevance_warn: int = 60 # >= this: Telegram warning, else reject pipeline_relevance_warn: int = 60 # >= this: Telegram warning, else reject
pipeline_max_drafts_per_day: int = 3 pipeline_max_drafts_per_day: int = 4
pipeline_publish_hours: str = "9,14" # comma-separated preferred publish hours (CET) pipeline_publish_hours: str = "9,12,15,18" # comma-separated preferred publish hours (CET)
pipeline_publish_start_hour: int = 9 pipeline_publish_start_hour: int = 9
pipeline_publish_end_hour: int = 19 pipeline_publish_end_hour: int = 19
pipeline_publish_min_gap_hours: int = 3 pipeline_publish_min_gap_hours: int = 3

View file

@ -2,8 +2,8 @@
Calculates suggested publish slots for new WordPress drafts. Calculates suggested publish slots for new WordPress drafts.
Rules: Rules:
- Preferred slots: configurable hours (default 09:00 and 14:00 CET/CEST) - Preferred slots: configurable hours (default 09:00, 12:00, 15:00, 18:00 CET/CEST)
- When the queue grows, additional slots are inserted with a minimum gap - The preferred hours define the daily publishing grid
- Scheduling only happens between the configured start/end hours - Scheduling only happens between the configured start/end hours
- New articles queue up after the last already-scheduled article - New articles queue up after the last already-scheduled article
- Checks both local DB AND WordPress future posts to avoid double-booking - Checks both local DB AND WordPress future posts to avoid double-booking
@ -47,7 +47,7 @@ def _preferred_hours() -> list[int]:
try: try:
preferred = [int(h.strip()) for h in settings.pipeline_publish_hours.split(",") if h.strip()] preferred = [int(h.strip()) for h in settings.pipeline_publish_hours.split(",") if h.strip()]
except Exception: except Exception:
preferred = [9, 14] preferred = [9, 12, 15, 18]
anchors: list[int] = [] anchors: list[int] = []
seen: set[int] = set() seen: set[int] = set()

View file

@ -60,7 +60,7 @@ class TestScheduler(unittest.TestCase):
return int(cur.lastrowid) return int(cur.lastrowid)
def test_preferred_hours_expand_with_gap_and_window(self) -> None: def test_preferred_hours_expand_with_gap_and_window(self) -> None:
self.assertEqual(_preferred_hours(), [9, 14, 17]) self.assertEqual(_preferred_hours(), [9, 12, 15, 18])
@patch("backend.app.scheduler._today_cet") @patch("backend.app.scheduler._today_cet")
@patch("backend.app.scheduler._fetch_wp_occupied_slots", return_value=set()) @patch("backend.app.scheduler._fetch_wp_occupied_slots", return_value=set())
@ -68,7 +68,7 @@ class TestScheduler(unittest.TestCase):
from datetime import date from datetime import date
mock_today.return_value = date(2026, 7, 24) mock_today.return_value = date(2026, 7, 24)
article_ids = [self._insert_article(idx) for idx in range(1, 5)] article_ids = [self._insert_article(idx) for idx in range(1, 6)]
slots = [] slots = []
for article_id in article_ids: for article_id in article_ids:
@ -84,8 +84,9 @@ class TestScheduler(unittest.TestCase):
slots, slots,
[ [
"2026-07-25T09:00:00", "2026-07-25T09:00:00",
"2026-07-25T14:00:00", "2026-07-25T12:00:00",
"2026-07-25T17:00:00", "2026-07-25T15:00:00",
"2026-07-25T18:00:00",
"2026-07-26T09:00:00", "2026-07-26T09:00:00",
], ],
) )

View file

@ -135,9 +135,9 @@ PIPELINE_RELEVANCE_WARN=60
## Veröffentlichungsplan ## Veröffentlichungsplan
- Standardmäßig **09:00 und 14:00 Uhr**, bei hohem Backlog zusätzlich weitere Slots - Standardmäßig **09:00, 12:00, 15:00 und 18:00 Uhr**
- Maximal **3 Beiträge pro Tag** im Standard-Setup - Maximal **4 Beiträge pro Tag** im Standard-Setup
- Zusätzliche Slots nur mit **mindestens 3 Stunden Abstand** - Zwischen den Slots liegen jeweils **3 Stunden Abstand**
- Veröffentlichungsfenster: **09:00 bis 19:00 Uhr** (`Europe/Berlin`) - Veröffentlichungsfenster: **09:00 bis 19:00 Uhr** (`Europe/Berlin`)
- Gleichmäßig über die Woche verteilt - Gleichmäßig über die Woche verteilt
- Der Vorschlag erscheint in der Telegram-Nachricht - Der Vorschlag erscheint in der Telegram-Nachricht
@ -145,8 +145,8 @@ PIPELINE_RELEVANCE_WARN=60
Einstellbar via: Einstellbar via:
``` ```
PIPELINE_MAX_DRAFTS_PER_DAY=3 PIPELINE_MAX_DRAFTS_PER_DAY=4
PIPELINE_PUBLISH_HOURS=9,14 PIPELINE_PUBLISH_HOURS=9,12,15,18
PIPELINE_PUBLISH_START_HOUR=9 PIPELINE_PUBLISH_START_HOUR=9
PIPELINE_PUBLISH_END_HOUR=19 PIPELINE_PUBLISH_END_HOUR=19
PIPELINE_PUBLISH_MIN_GAP_HOURS=3 PIPELINE_PUBLISH_MIN_GAP_HOURS=3