Skip to content

Commit

Permalink
Merge pull request #215 from nathanegillett/rm-crud
Browse files Browse the repository at this point in the history
Remove crud module
  • Loading branch information
negillett committed Feb 25, 2021
2 parents b482012 + a9be2d7 commit 9d04807
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
38 changes: 0 additions & 38 deletions exodus_gw/crud.py

This file was deleted.

18 changes: 14 additions & 4 deletions exodus_gw/routers/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
import logging
from datetime import datetime, timezone
from typing import Dict, List, Union
from uuid import UUID
from uuid import UUID, uuid4

from fastapi import APIRouter, Body, HTTPException
from sqlalchemy.orm import Session

from .. import deps, models, schemas, worker
from ..crud import create_publish, update_publish
from ..aws.util import validate_object_key
from ..settings import Environment, Settings

LOG = logging.getLogger("exodus-gw")
Expand Down Expand Up @@ -106,7 +106,10 @@ def publish(
) -> models.Publish:
"""Creates and returns a new publish object."""

return create_publish(env, db)
db_publish = models.Publish(id=uuid4(), env=env.name, state="PENDING")
db.add(db_publish)

return db_publish


@router.put(
Expand Down Expand Up @@ -157,7 +160,14 @@ def update_publish_items(
% (db_publish.id, db_publish.state),
)

update_publish(db, items, db_publish.id)
# Coerce single items to list.
if not isinstance(items, list):
items = [items]

for item in items:
validate_object_key(item.object_key)

db.add(models.Item(**item.dict(), publish_id=db_publish.id))

return {}

Expand Down

0 comments on commit 9d04807

Please sign in to comment.