Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue 642] Filter to only opportunities that are not drafts #709

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

chouinar
Copy link
Collaborator

Summary

Fixes #642

Time to review: 5 mins

Changes proposed

Made it so the search endpoint always filters to is_draft=False

Remove the ability for the user to filter by is_draft

Removed is_draft from the opportunity response model

Context for reviewers

We don't want to expose draft opportunities in the search, so always filter them.

Additional information

I populated my local DB with 50 opportunity records, randomly between is_draft True/False

select count(*) from topportunity where is_draft=False returns 21 records, so using the search endpoint with no filters should give the same result.

A request of:

{
  "paging": {
    "page_offset": 1,
    "page_size": 25
  },
  "sorting": {
    "order_by": "opportunity_id",
    "sort_direction": "ascending"
  }
}

Gives the following pagination info in the response:

"pagination_info": {
    "order_by": "opportunity_id",
    "page_offset": 1,
    "page_size": 25,
    "sort_direction": "ascending",
    "total_pages": 1,
    "total_records": 21
  }

stmt = (
select(Opportunity)
.order_by(sort_fn(getattr(Opportunity, search_params.sorting.order_by)))
.where(Opportunity.is_draft.is_(False)) # Only ever return non-drafts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be added to the api/src/services/opportunities/get_opportunities.py select query as well in order to keep is_draft == False opportunities from being shared in the GET endpoint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that at some point we'll be building out the ability to modify drafts, and we'd need the GET endpoint to return them, but we'll use whatever auth we build out to restrict whether someone can see a draft opportunity or not?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current understanding is that the drafts should not be viewable to the general public, and that they would only be viewable by the grant org admins. Providing any drafts would require authenticating to the current system, which I imagine at this point is pretty far in the future.

@chouinar chouinar requested a review from acouch November 17, 2023 17:09
@chouinar chouinar merged commit 9f7c58f into main Nov 17, 2023
7 checks passed
@chouinar chouinar deleted the chouinar/642-is-draft-filter branch November 17, 2023 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Filter "is_draft" is false for all opportunities and remove is_draft from the opportunity schema
3 participants