-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/project crud (sprint 1) #1
Conversation
…add mongo-expers web client
The error was caused by a missing message field in the request and response in the object stored in the database. It is possible that this depends on the AI model used.
More specific data in other in transaction view
added simple form for project adding
crud for projects via ui done
updated endpoints and what they returns, model_name changed to ai_model_name in ProjectAIProviderSchema, updated api tests
src/app/web_api.py
Outdated
|
||
|
||
@app.get("/api/projects", response_class=JSONResponse) | ||
async def get_projects(request: Request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dodaj zwracany typ
src/app/web_api.py
Outdated
return projects | ||
|
||
|
||
@app.get("/api/projects/{project_id}", response_class=JSONResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dodaj zwracany typ
src/app/web_api.py
Outdated
|
||
|
||
@app.get("/api/projects/{project_id}", response_class=JSONResponse) | ||
async def get_specific_project(request: Request, project_id: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_specific_project -> get_project_details
dodaj zwracany typ
src/app/web_api.py
Outdated
ctx = get_transaction_context(request) | ||
transactions = ctx.call(get_transactions_for_project, project_id=project_id) | ||
project = ctx.call(get_project, project_id=project_id) | ||
if project is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ten if jest tu niepotrzebny. jeżeli projektu nie ma, to repozytorium powinno rzucić wyj
ątkiem, a fastapi powinno przechwycić ten wyjątek i na tej podstawie wyświetlić 404.
https://fastapi.tiangolo.com/tutorial/handling-errors/#override-request-validation-exceptions
src/app/web_api.py
Outdated
return project | ||
|
||
|
||
@app.post("/api/projects", response_class=JSONResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brak zwracanego typu, upewnij się że endpoint zwraca kod 200
src/projects/use_cases.py
Outdated
slug: str, | ||
project_repository: ProjectRepository, | ||
) -> Project: | ||
project = project_repository.find_one({"slug": slug}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j.w. dlaczego nie prościej - get_by_slug(slug)
src/projects/use_cases.py
Outdated
project_repository: ProjectRepository, | ||
) -> Project | None: | ||
if project_repository.find_one({"slug": data.slug}): | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tu rzuć wyjątkiem SlugAlreadyExistsError
zamiast zwracać None
src/projects/use_cases.py
Outdated
) -> Project | None: | ||
if project_repository.find_one({"slug": data.slug}): | ||
return None | ||
data = Project(**data.model_dump()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project = Project(...)
src/projects/use_cases.py
Outdated
project_repository: ProjectRepository | ||
) -> bool: | ||
update_result = project_repository.update(data) | ||
if update_result.modified_count == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
czy ta logka jest w ogóle potrzeba? jak projektu nie ma to repo powinno rzucić wyjątkiem
src/projects/use_cases.py
Outdated
project_id: str, | ||
project_repository: ProjectRepository, | ||
) -> bool: | ||
delete_result = project_repository.delete(project_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
czy ta logka jest w ogóle potrzeba? jak projektu nie ma to repo powinno rzucić wyjątkiem
Added: