from arq.connections import RedisSettings from sqlalchemy import select from sqlalchemy.orm import selectinload from app.core.config import settings from app.core.database import AsyncSessionLocal from app.models.notes import NoteItem from app.services.notes_markdown import delete_note_markdown, save_note_markdown async def export_note_markdown(ctx: dict, note_id: str) -> None: async with AsyncSessionLocal() as session: stmt = ( select(NoteItem) .where(NoteItem.id == note_id) .options(selectinload(NoteItem.attachments)) ) result = await session.execute(stmt) note = result.scalar_one_or_none() if note: save_note_markdown(note) async def remove_note_markdown(ctx: dict, note_id: str) -> None: delete_note_markdown(note_id) class WorkerSettings: functions = [export_note_markdown, remove_note_markdown] redis_settings = RedisSettings.from_dsn(settings.redis_url)