19 lines
No EOL
806 B
Python
19 lines
No EOL
806 B
Python
import re
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from ..models.summarise_job import SummariseJob
|
|
from ..models.translated_article import TranslatedArticle
|
|
from ...outbound.postgres.repositories.translated_article_repository import TranslatedArticleRepository
|
|
|
|
def first_heading(md: str) -> str | None:
|
|
m = re.search(r'^#{1,2}\s+(.+)', md, re.MULTILINE)
|
|
return m.group(1).strip() if m else None
|
|
|
|
class ArticleService:
|
|
def __init__(self, db: AsyncSession) -> None:
|
|
self.translated_articles_repository = TranslatedArticleRepository(db)
|
|
|
|
async def get_all_articles(self, target_language: str) -> list[TranslatedArticle]:
|
|
"""Fetch all translated articles"""
|
|
articles = await self.translated_articles_repository.list_all(target_language)
|
|
return articles |