-
-
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.
refactor: add types to find_one_entry routes + start refactor Propert…
…yTable (#481) * feat: add EntryNode type for find_one_entry route * fix: update frontend to handle new API * fix: lint backend * fix: respond to comment
- Loading branch information
1 parent
6003639
commit cc7df50
Showing
12 changed files
with
188 additions
and
89 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from fastapi import HTTPException | ||
from neo4j import AsyncResult, Record | ||
|
||
|
||
async def get_unique_record(result: AsyncResult, record_id: str | None = None) -> Record: | ||
""" | ||
Gets the unique record from a Cypher query result | ||
Raises: | ||
404 HTTPException: If no record is found | ||
500 HTTPException: If multiple records are found | ||
""" | ||
record = await result.fetch(1) | ||
if record is None: | ||
exception_message = f"Record {record_id} not found" if record_id else "Record not found" | ||
raise HTTPException(status_code=404, detail=exception_message) | ||
|
||
remaining_record = await result.peek() | ||
if remaining_record is not None: | ||
exception_message = ( | ||
f"Multiple records with id {record_id} found" if record_id else "Multiple records found" | ||
) | ||
raise HTTPException( | ||
status_code=500, | ||
detail=exception_message, | ||
) | ||
|
||
return record[0] |
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 +1,18 @@ | ||
/** | ||
* @deprecated Migrate to @/client/models/EntryNode when possible | ||
*/ | ||
export type DestructuredEntryNode = { | ||
id: string; | ||
precedingLines: Array<string>; | ||
srcPosition: number; | ||
mainLanguage: string; | ||
isExternal: boolean; | ||
originalTaxonomy: string | null; | ||
// TODO: Use updated types from the API | ||
[key: string]: any; | ||
// tags: Record<string, Array<string>>; | ||
// properties: Record<string, string>; | ||
// comments: Record<string, Array<string>>; | ||
}; | ||
|
||
export type ParentsAPIResponse = string[]; |
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
Oops, something went wrong.