Use four fixed daily publish slots
This commit is contained in:
parent
50f29cc948
commit
90646d03a6
5 changed files with 17 additions and 16 deletions
|
|
@ -40,9 +40,9 @@ PIPELINE_RELEVANCE_AUTO=80
|
|||
# Relevanz-Score >= dieser Wert, aber < AUTO: Telegram-Warnung senden
|
||||
PIPELINE_RELEVANCE_WARN=60
|
||||
# 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)
|
||||
PIPELINE_PUBLISH_HOURS=9,14
|
||||
PIPELINE_PUBLISH_HOURS=9,12,15,18
|
||||
# Frühester/spätester Slot sowie Mindestabstand für zusätzliche Slots
|
||||
PIPELINE_PUBLISH_START_HOUR=9
|
||||
PIPELINE_PUBLISH_END_HOUR=19
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ class Settings(BaseSettings):
|
|||
# Pipeline behaviour
|
||||
pipeline_relevance_auto: int = 80 # >= this: auto-process
|
||||
pipeline_relevance_warn: int = 60 # >= this: Telegram warning, else reject
|
||||
pipeline_max_drafts_per_day: int = 3
|
||||
pipeline_publish_hours: str = "9,14" # comma-separated preferred publish hours (CET)
|
||||
pipeline_max_drafts_per_day: int = 4
|
||||
pipeline_publish_hours: str = "9,12,15,18" # comma-separated preferred publish hours (CET)
|
||||
pipeline_publish_start_hour: int = 9
|
||||
pipeline_publish_end_hour: int = 19
|
||||
pipeline_publish_min_gap_hours: int = 3
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
Calculates suggested publish slots for new WordPress drafts.
|
||||
Rules:
|
||||
- Preferred slots: configurable hours (default 09:00 and 14:00 CET/CEST)
|
||||
- When the queue grows, additional slots are inserted with a minimum gap
|
||||
- Preferred slots: configurable hours (default 09:00, 12:00, 15:00, 18:00 CET/CEST)
|
||||
- The preferred hours define the daily publishing grid
|
||||
- Scheduling only happens between the configured start/end hours
|
||||
- New articles queue up after the last already-scheduled article
|
||||
- Checks both local DB AND WordPress future posts to avoid double-booking
|
||||
|
|
@ -47,7 +47,7 @@ def _preferred_hours() -> list[int]:
|
|||
try:
|
||||
preferred = [int(h.strip()) for h in settings.pipeline_publish_hours.split(",") if h.strip()]
|
||||
except Exception:
|
||||
preferred = [9, 14]
|
||||
preferred = [9, 12, 15, 18]
|
||||
|
||||
anchors: list[int] = []
|
||||
seen: set[int] = set()
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class TestScheduler(unittest.TestCase):
|
|||
return int(cur.lastrowid)
|
||||
|
||||
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._fetch_wp_occupied_slots", return_value=set())
|
||||
|
|
@ -68,7 +68,7 @@ class TestScheduler(unittest.TestCase):
|
|||
from datetime import date
|
||||
|
||||
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 = []
|
||||
for article_id in article_ids:
|
||||
|
|
@ -84,8 +84,9 @@ class TestScheduler(unittest.TestCase):
|
|||
slots,
|
||||
[
|
||||
"2026-07-25T09:00:00",
|
||||
"2026-07-25T14:00:00",
|
||||
"2026-07-25T17:00:00",
|
||||
"2026-07-25T12:00:00",
|
||||
"2026-07-25T15:00:00",
|
||||
"2026-07-25T18:00:00",
|
||||
"2026-07-26T09:00:00",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue