-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update GitHub functions (#368)
* refactor: replace pygithub by githubkit for async HTTP requests * refactor: move to AsyncTxnCtx in Background Tasks and fix Github export * refactor: refactor edit_project controller * feat: export to Github from correct SHA * refactor: move file_cleanup closer to unparser * fix: run dump_taxonomy in thread_pool * fix: raise 422 error if project not from github * fix: linting * tooling: Update isort and flake8 settings * fix: linting * feat: create new commit when exporting an exported taxonomy * refactor: refactor ExportTaxonomyToGithub * chore: update frontend messages * test: remove flaky tests * test: fix failing test * fix: fix bnrach uniqueness for upload case * fix: delete unused file * fix: resolve comments
- Loading branch information
1 parent
fdde28c
commit 3fefb1d
Showing
16 changed files
with
487 additions
and
690 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from ..graph_db import get_current_transaction | ||
from ..models.project_models import Project, ProjectCreate, ProjectEdit | ||
|
||
|
||
async def get_project(project_id: str) -> Project: | ||
""" | ||
Get project by id | ||
""" | ||
query = """ | ||
MATCH (p:PROJECT {id: $project_id}) | ||
RETURN p | ||
""" | ||
params = {"project_id": project_id} | ||
result = await get_current_transaction().run(query, params) | ||
return Project(**(await result.single())["p"]) | ||
|
||
|
||
async def create_project(project: ProjectCreate): | ||
""" | ||
Create project | ||
""" | ||
query = """ | ||
CREATE (p:PROJECT $project) SET p.created_at = datetime() | ||
""" | ||
params = {"project": project.model_dump()} | ||
await get_current_transaction().run(query, params) | ||
|
||
|
||
async def edit_project(project_id: str, project_edit: ProjectEdit): | ||
""" | ||
Edit project | ||
""" | ||
query = """ | ||
MATCH (p:PROJECT {id: $project_id}) | ||
SET p += $project_edit | ||
""" | ||
params = { | ||
"project_id": project_id, | ||
"project_edit": project_edit.model_dump(exclude_unset=True), | ||
} | ||
await get_current_transaction().run(query, params) |
Oops, something went wrong.