completely useless tap logic
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from fastapi import Depends, HTTPException
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from typing import Annotated
|
||||
from sqlalchemy.orm import Session
|
||||
from uuid import UUID
|
||||
|
||||
from ...dependencies import get_db
|
||||
from ...db import models
|
||||
@ -35,3 +36,15 @@ def create_news(
|
||||
detail="Could not validate credentials",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
|
||||
def tap_news(news_id: UUID, db: Session):
|
||||
n = db.query(models.News).filter(models.News.id == news_id).first()
|
||||
if n:
|
||||
setattr(n, "taps", n.taps + 1)
|
||||
db.commit()
|
||||
return
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Not found",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user