-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
facility_cycles -> list cycles for a facility beamline_by_name -> returns beamline given the name (TLA)
- Loading branch information
1 parent
dcb55f9
commit 847fc85
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
from typing import Optional | ||
|
||
from nsls2api.models.beamlines import Beamline | ||
|
||
|
||
async def beamline_count() -> int: | ||
return await Beamline.count() | ||
|
||
|
||
async def beamline_by_name(name: str) -> Optional[Beamline]: | ||
# TODO: check that the input name looks sensible | ||
# TODO: make this case insensitive | ||
beamline = await Beamline.find_one(Beamline.name == name) | ||
return beamline | ||
|
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,5 +1,24 @@ | ||
from nsls2api.models.facilities import Facility | ||
from nsls2api.models.cycles import Cycle | ||
|
||
|
||
async def facilities_count() -> int: | ||
""" | ||
Count the number of facilities in the database. | ||
:return: The number of facilities. | ||
""" | ||
return await Facility.count() | ||
|
||
|
||
async def facility_cycles(facility: str): | ||
""" | ||
Facility Cycles | ||
This method retrieves the cycles for a given facility. | ||
:param facility: The facility name (str). | ||
:return: A list of cycles for the facility (list[Cycle]). | ||
""" | ||
cycles = await Cycle.find(Cycle.facility == facility) | ||
return cycles |