Skip to content

Commit

Permalink
Added LBMS proposals per cycle stats
Browse files Browse the repository at this point in the history
This really needs a rethink - but for now just add the LBMS stats.
  • Loading branch information
stuartcampbell committed Jan 9, 2025
1 parent 3c60336 commit 452d7a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/nsls2api/api/models/stats_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class StatsModel(pydantic.BaseModel):
beamline_count: int
commissioning_proposal_count: int
facility_data_health: bool
nsls2_proposals_per_cycle: Optional[list[ProposalsPerCycleModel]] = []
nsls2_proposals_per_cycle: Optional[list[ProposalsPerCycleModel]]
lbms_proposals_per_cycle: Optional[list[ProposalsPerCycleModel]]


class AboutModel(pydantic.BaseModel):
Expand Down
14 changes: 13 additions & 1 deletion src/nsls2api/api/v1/stats_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async def stats():

facility_data_health = await facility_service.is_healthy("nsls2")

# Get the NSLS-II proposals per cycle
nsls2_proposals_per_cycle: list[ProposalsPerCycleModel] = []

nsls2_cycle_list = await facility_service.facility_cycles("nsls2")
for cycle in nsls2_cycle_list:
proposal_list = await proposal_service.fetch_proposals_for_cycle(cycle)
Expand All @@ -35,13 +35,25 @@ async def stats():
)
nsls2_proposals_per_cycle.append(model)

# Get the LBMS proposals per cycle
lbms_proposals_per_cycle: list[ProposalsPerCycleModel] = []
lbms_cycle_list = await facility_service.facility_cycles("lbms")
for cycle in lbms_cycle_list:
proposal_list = await proposal_service.fetch_proposals_for_cycle(cycle)
if proposal_list is not None:
model = ProposalsPerCycleModel(
cycle=cycle, proposal_count=len(proposal_list)
)
lbms_proposals_per_cycle.append(model)

model = StatsModel(
facility_count=facilities,
beamline_count=beamlines,
proposal_count=total_proposals,
commissioning_proposal_count=commissioning,
facility_data_health=facility_data_health,
nsls2_proposals_per_cycle=nsls2_proposals_per_cycle,
lbms_proposals_per_cycle=lbms_proposals_per_cycle,
)
return model

Expand Down

0 comments on commit 452d7a5

Please sign in to comment.