Skip to content
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

Merged
merged 41 commits into from
Dec 8, 2023
Merged

Feature/project crud (sprint 1) #1

merged 41 commits into from
Dec 8, 2023

Conversation

sliwaszymon
Copy link
Contributor

Added:

  • project crud
  • webui endpoints (to trash in future)
  • api endpoints (forSPA)
  • api tests
  • saving transaction "as is"
  • single transaction view
  • project model updated
  • frontend for webui in jinja2
  • minor fixes

ksopyla and others added 30 commits October 22, 2023 21:16
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
@sliwaszymon sliwaszymon requested a review from pgorecki November 27, 2023 15:08
@sliwaszymon sliwaszymon self-assigned this Nov 27, 2023


@app.get("/api/projects", response_class=JSONResponse)
async def get_projects(request: Request):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dodaj zwracany typ

return projects


@app.get("/api/projects/{project_id}", response_class=JSONResponse)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dodaj zwracany typ



@app.get("/api/projects/{project_id}", response_class=JSONResponse)
async def get_specific_project(request: Request, project_id: str):
Copy link
Collaborator

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

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:
Copy link
Collaborator

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

return project


@app.post("/api/projects", response_class=JSONResponse)
Copy link
Collaborator

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

slug: str,
project_repository: ProjectRepository,
) -> Project:
project = project_repository.find_one({"slug": slug})
Copy link
Collaborator

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)

project_repository: ProjectRepository,
) -> Project | None:
if project_repository.find_one({"slug": data.slug}):
return None
Copy link
Collaborator

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

) -> Project | None:
if project_repository.find_one({"slug": data.slug}):
return None
data = Project(**data.model_dump())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project = Project(...)

project_repository: ProjectRepository
) -> bool:
update_result = project_repository.update(data)
if update_result.modified_count == 0:
Copy link
Collaborator

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

project_id: str,
project_repository: ProjectRepository,
) -> bool:
delete_result = project_repository.delete(project_id)
Copy link
Collaborator

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

@pgorecki pgorecki merged commit d940ad2 into main Dec 8, 2023
@pgorecki pgorecki deleted the feature/project-crud branch December 8, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants