Enhance proposals endpoint with optional username, cycle, and SAF status filters for MX Webapp#257
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the v1/proposals/ admin endpoint to support optional filtering intended for MX Webapp workflows (username-scoped queries, current-cycle-only selection, and SAF status filtering) while keeping the endpoint path and response schema unchanged.
Changes:
- Added an optional
usernamefilter to the proposals fetch service (query-level filtering before pagination). - Extended the
v1/proposals/API route withusername,current_cycle_only, andsaf_statusquery parameters. - Added route-level post-filtering to constrain returned SAF entries (and optionally proposals) based on provided filters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/nsls2api/services/proposal_service.py |
Adds optional username-based DB filtering to fetch_proposals. |
src/nsls2api/api/v1/proposal_api.py |
Wires new query params into the proposals endpoint and applies post-filter logic for cycles/SAFs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Padraic Shafer (padraic-shafer)
left a comment
There was a problem hiding this comment.
I've included recommendations for tightening this up.
|
Hi Padraic Shafer (@padraic-shafer)
|
|
Aditi Chikkali (@AditiChikkali) You are absolutely correct that the lists should default to For strings, it comes down to whether |
|
I think current cycle should get resolved client-side. If a "current cycle" convenience is truly necessary, I think it might fit better into a |
You are right the current-cycle is convenience parameter is not strictly necessary. My thinking was mainly, when we pass a cycle filter, the returned proposal can still show other historical cycles in its cycle list, and for the app form we wanted to clearly restrict and display it as the current cycle context. Since the server already knows the current cycle, I thought we could use that to simplify client handling and keep the form automatically tied to the active cycle. That said, I agree with your direction and will remove the current_cycle_only parameter, and we could jut make use of existing explicit cycle input. |
Padraic Shafer (padraic-shafer)
left a comment
There was a problem hiding this comment.
I've requested some changes on the function signatures.
Also, I'm confused by what you are trying to achieve with the SAF handling. The custom logic seems unnecessarily complex to me, so I might be misunderstanding the goal of what you want to happen.
Summary
This PR enhances the v1/proposals endpoint to add optional filtering by username, cycle, and SAF status, improving accuracy and enabling user‑scoped queries without introducing new endpoints to support MX workflow needs for user‑specific proposal retrieval.
Key Changes
• username
• current_cycle_only
• saf_status
Behavior & Compatibility