Skip to content

Commit

Permalink
method for saving bulk assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
bailliekova committed Jul 21, 2024
1 parent 07d14ac commit 301b9f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from sqlalchemy import text
from sqlmodel import Session
from starlette.middleware.cors import CORSMiddleware
from typing import List
import logging

import sentry_sdk
from app.core.db import engine
from app.core.config import settings
from app.models import Document
from app.models import Assignments, Document

if settings.ENVIRONMENT == "production":
sentry_sdk.init(
Expand Down Expand Up @@ -73,3 +74,11 @@ async def create_document(session: Session = Depends(get_session)):
)
)
return doc


@app.post("/update_assignments")
async def update_assignments(
assignments: List[Assignments], session: Session = Depends(get_session)
):
session.bulk_save_objects(assignments)
session.commit()

0 comments on commit 301b9f1

Please sign in to comment.