-
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.
- Loading branch information
Showing
30 changed files
with
413 additions
and
37 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
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,12 @@ | ||
from lims_utils.tables import Movie | ||
from sqlalchemy import select | ||
|
||
from ..utils.database import db | ||
|
||
|
||
def get_movies(foil_hole_id: int, page: int, limit: int): | ||
query = select(Movie).filter(Movie.foilHoleId == foil_hole_id) | ||
|
||
return db.paginate( | ||
query=query, limit=limit, page=page, slow_count=False, scalar=False | ||
) |
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,23 @@ | ||
from lims_utils.tables import FoilHole, GridSquare | ||
from sqlalchemy import select | ||
|
||
from ..utils.database import db | ||
|
||
|
||
def get_foil_holes(grid_square_id: int, page: int, limit: int): | ||
query = select( | ||
FoilHole.pixelLocationX, | ||
FoilHole.pixelLocationY, | ||
FoilHole.diameter, | ||
FoilHole.foilHoleId, | ||
).filter(FoilHole.gridSquareId == grid_square_id) | ||
|
||
return db.paginate(query=query, limit=limit, page=page, slow_count=False) | ||
|
||
|
||
def get_grid_square_image(grid_square_id: int): | ||
return db.session.scalar( | ||
select(GridSquare.gridSquareImage).filter( | ||
GridSquare.gridSquareId == grid_square_id | ||
) | ||
) |
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,20 @@ | ||
from fastapi import APIRouter, Depends | ||
from lims_utils.models import Paged, pagination | ||
|
||
from ..auth import Permissions | ||
from ..crud import foil_holes as crud | ||
from ..models.response import Movie | ||
|
||
router = APIRouter( | ||
tags=["Foil Holes"], | ||
prefix="/foil-holes", | ||
) | ||
|
||
|
||
@router.get("/{foilHoleId}/movies", response_model=Paged[Movie]) | ||
def get_movies( | ||
foilHoleId: int = Depends(Permissions.foil_hole), | ||
page: dict[str, int] = Depends(pagination), | ||
): | ||
"""Get movies in a foil hole""" | ||
return crud.get_movies(foil_hole_id=foilHoleId, **page) |
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,27 @@ | ||
from fastapi import APIRouter, Depends | ||
from fastapi.responses import FileResponse | ||
from lims_utils.models import Paged, pagination | ||
|
||
from ..auth import Permissions | ||
from ..crud import grid_squares as crud | ||
from ..models.response import FoilHole | ||
|
||
router = APIRouter( | ||
tags=["Grid Squares"], | ||
prefix="/grid-squares", | ||
) | ||
|
||
|
||
@router.get("/{gridSquareId}/foil-holes", response_model=Paged[FoilHole]) | ||
def get_foil_holes( | ||
gridSquareId: int = Depends(Permissions.grid_square), | ||
page: dict[str, int] = Depends(pagination), | ||
): | ||
"""Get foil holes in a grid square""" | ||
return crud.get_foil_holes(grid_square_id=gridSquareId, **page) | ||
|
||
|
||
@router.get("/{gridSquareId}/image", response_class=FileResponse) | ||
def get_grid_square_image(gridSquareId: int = Depends(Permissions.grid_square)): | ||
"""Get image of grid square""" | ||
return crud.get_grid_square_image(grid_square_id=gridSquareId) |
Oops, something went wrong.