feat: aggregate articles across newspapers and limit to 30 with whitespace cleanup

This commit is contained in:
retoor 2025-10-06 06:04:14 +00:00
parent 3e804dcea9
commit 367b5043cb

View File

@ -555,15 +555,15 @@ async def newspaper_latest(request: Request):
newspapers= list(db.query("select * from newspapers order by id desc limit 10")) newspapers= list(db.query("select * from newspapers order by id desc limit 10"))
except IndexError: except IndexError:
pass pass
articles = []
for newspaper in newspapers: for newspaper in newspapers:
articles = json.loads(newspaper['articles_json']) articles += json.loads(newspaper['articles_json'])
if articles: if len(articles) > 30:
for article in articles: for article in articles:
for key, value in article.items(): for key, value in article.items():
article[key] = str(value).strip() article[key] = str(value).strip().replace(' ', '')
return templates.TemplateResponse("newspaper_view.html", { return templates.TemplateResponse("newspaper_view.html", {
"request": request, "request": request,
"newspaper": newspaper, "newspaper": newspaper,