forked from retoor/devplacepy
feat: add featured/locked columns and auto-rotation logic to news pipeline
- Add `ai_grade`, `featured`, `featured_locked`, `landing_locked`, `author`, `article_published`, `image_url`, `has_unique_image` columns to news table - Extend `news_images` schema with `alt_text`, `phash`, `width`, `height`, `is_placeholder` columns - Create `idx_news_featured` index for efficient featured queries - Update admin toggle endpoints to set `featured_locked`/`landing_locked` when manually toggling - Propagate `featured` and `image_url` fields through landing page, news list, and detail page rendering - Update `get_featured_news` to return `featured` and `image_url` fields - Document in AGENTS.md the full zero-maintenance pipeline: image perceptual hashing, placeholder detection, AI grading on cleaned text, reliability gate, effective score computation, and post-loop landing rotation - Update README.md service description to reflect automatic image comparison and landing rotation capabilities - Clarify docs_api.py summaries that toggling featured/landing now locks articles from auto-rotation
This commit is contained in:
@@ -62,8 +62,9 @@ async def news_page(request: Request, before: str = None):
|
||||
{
|
||||
"article": a,
|
||||
"time_ago": time_ago(a["synced_at"]),
|
||||
"image_url": images_by_news.get(a["uid"]),
|
||||
"image_url": a.get("image_url", "") or images_by_news.get(a["uid"]),
|
||||
"grade": a.get("grade", 0),
|
||||
"featured": a.get("featured", 0),
|
||||
"recent_comments": recent_comments.get(a["uid"], []),
|
||||
}
|
||||
)
|
||||
@@ -104,10 +105,10 @@ async def news_detail_page(request: Request, news_slug: str):
|
||||
if redirect:
|
||||
return redirect
|
||||
|
||||
image_url = ""
|
||||
if "news_images" in db.tables:
|
||||
image_url = article.get("image_url", "") or ""
|
||||
if not image_url and "news_images" in db.tables:
|
||||
img = get_table("news_images").find_one(
|
||||
news_uid=article["uid"], deleted_at=None
|
||||
news_uid=article["uid"], deleted_at=None, is_placeholder=0
|
||||
)
|
||||
if img:
|
||||
image_url = img["url"]
|
||||
|
||||
Reference in New Issue
Block a user