Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
machado2 committed Jul 1, 2024
1 parent ce9446c commit 96dfb77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/article_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Headline:

async def get_next_page(params: ContentListParams) -> List[Headline]:
page_size = 20 if not params.page_size or params.page_size > 100 else params.page_size
query = Content.filter(flagged=False)
query = Content.filter(flagged=False, image_id__isnull=False, markdown__isnull=False)

if params.search:
query = query.filter(
Expand Down
13 changes: 2 additions & 11 deletions app/get_content.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from uuid import uuid4

import markdown_it
from fastapi import APIRouter, HTTPException, Request, BackgroundTasks
from starlette.responses import HTMLResponse, RedirectResponse
from starlette.responses import HTMLResponse

from app.create import create_article_and_remove_task
from app.models import Content
from app.template import render_template
from app.wait import background_ids

router = APIRouter()

Expand All @@ -18,12 +14,7 @@
async def get_content(request: Request, background_tasks: BackgroundTasks, slug: str):
content = await Content.filter(slug=slug).first()
if content is None:
if len(background_ids) > 0:
raise HTTPException(status_code=404, detail="Content not found")
identifier = str(uuid4())
background_ids[identifier] = True
background_tasks.add_task(create_article_and_remove_task, identifier, slug)
return RedirectResponse(url=f"/wait/{identifier}", status_code=303)
raise HTTPException(status_code=404, detail="Content not found")
html = markdown.render(content.markdown or "")
return render_template(
"content.html", request,
Expand Down

0 comments on commit 96dfb77

Please sign in to comment.