-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description - add getting market data route & method - fix aws config - add s3 get with data url ## Related Issue Closes #17
- Loading branch information
Showing
6 changed files
with
129 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from sqlalchemy.orm import Session | ||
from app.models.domain import posts | ||
from app.models.schemas.posts import Post | ||
from app.services.aws import s3_upload | ||
from fastapi import HTTPException | ||
from app.services.aws import s3_upload, s3_get | ||
from fastapi import HTTPException, UploadFile | ||
from fastapi import UploadFile | ||
from typing import List | ||
from typing import List, Tuple, Any | ||
import datetime | ||
from app.models.domain import markets | ||
from app.crud.crud_markets import get as get_market | ||
|
||
|
||
def create(db: Session, *, obj_in: posts.PostCreate, files: List[UploadFile]) -> Post: | ||
|
@@ -15,6 +17,7 @@ def create(db: Session, *, obj_in: posts.PostCreate, files: List[UploadFile]) -> | |
status=obj_in.status, | ||
category=obj_in.category, | ||
created_at=datetime.datetime.today(), | ||
user_id=1, # should be changed with user email | ||
) | ||
# image bool value insert | ||
db_obj.image = True if files else False | ||
|
@@ -35,3 +38,26 @@ def create(db: Session, *, obj_in: posts.PostCreate, files: List[UploadFile]) -> | |
detail="s3 upload failed", | ||
) | ||
return db_obj | ||
|
||
|
||
def get( | ||
db: Session, *, category: str, post_id: int | ||
) -> list[markets.MarketGet] | list[Any]: | ||
post_data = db.query(Post).filter(Post.id == post_id).one() | ||
if category == "market": | ||
if post_data.image: | ||
file_list = s3_get( | ||
post_id=post_data.id, | ||
user_email="[email protected]", | ||
category=category, | ||
) | ||
result = get_market( | ||
db, post_id=post_id, post_data=post_data, file_list=file_list | ||
) | ||
return result | ||
else: | ||
result = get_market(db, post_id=post_id, post_data=post_data, file_list=[]) | ||
return result | ||
|
||
else: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters