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 #1364] Update API schema with modified DB schema fields #1448

Merged
merged 18 commits into from
Mar 14, 2024

Conversation

chouinar
Copy link
Collaborator

@chouinar chouinar commented Mar 7, 2024

Summary

Fixes #1364

Time to review: 10 mins

Changes proposed

Updated the API schema to match the updated database schema

Fixed various tests, updated a few factory utilities

Context for reviewers

Nothing too elaborate here, did add a filter to only include records if the current_opportunity_summary is not null (eg. it has a current summary).

Additional information

For testing locally, you can seed your DB with make db-seed-local.

Here is what a response looks like (page size = 3)
{
  "data": [
    {
      "agency": "US-ABC",
      "category": "earmark",
      "category_explanation": null,
      "created_at": "2024-03-07T16:48:01.473826+00:00",
      "opportunity_assistance_listings": [
        {
          "assistance_listing_number": "09.729",
          "program_title": "Patrick-Davenport"
        },
        {
          "assistance_listing_number": "69.903",
          "program_title": "James-Melton"
        },
        {
          "assistance_listing_number": "89.003",
          "program_title": "Gonzalez, Harris and Gutierrez"
        }
      ],
      "opportunity_id": 1,
      "opportunity_number": "ABC-1-XYZ-001",
      "opportunity_status": "forecasted",
      "opportunity_title": "Research into Air traffic controller industry",
      "summary": {
        "additional_info_url": "google.com",
        "additional_info_url_description": "Click me for additional info",
        "agency_code": "US-ABC",
        "agency_contact_description": "For more information contact us at - Recognize how others wish way. Sign present manage head. Mind coach successful education.",
        "agency_email_address": "[email protected]",
        "agency_email_address_description": "Contact US Alphabetical Basic Corp via email",
        "agency_name": "US Alphabetical Basic Corp",
        "agency_phone_number": "123-456-0000",
        "applicant_eligibility_description": null,
        "applicant_types": [
          "county_governments",
          "state_governments"
        ],
        "archive_date": "2024-03-30",
        "award_ceiling": 8780000,
        "award_floor": 627142,
        "close_date": null,
        "close_date_description": null,
        "estimated_total_program_funding": 8780000,
        "expected_number_of_awards": 14,
        "fiscal_year": 2025,
        "forecasted_award_date": "2024-09-07",
        "forecasted_close_date": "2024-04-19",
        "forecasted_close_date_description": "Writer history suffer catch let high.",
        "forecasted_post_date": "2024-03-21",
        "forecasted_project_start_date": "2025-02-23",
        "funding_categories": [
          "recovery_act",
          "agriculture"
        ],
        "funding_category_description": "Whether why answer section.",
        "funding_instruments": [
          "grant",
          "procurement_contract",
          "cooperative_agreement"
        ],
        "is_cost_sharing": true,
        "is_forecast": true,
        "post_date": "2024-02-22",
        "summary_description": "Example summary - Air and company significant or. Discussion argue do section exactly race. Provide turn management record anything large. In Mrs rule others whole."
      },
      "updated_at": "2024-03-07T16:48:01.473826+00:00"
    },
    {
      "agency": "US-XYZ",
      "category": "continuation",
      "category_explanation": null,
      "created_at": "2024-03-07T16:48:01.576121+00:00",
      "opportunity_assistance_listings": [
        {
          "assistance_listing_number": "33.767",
          "program_title": "Martinez Group"
        },
        {
          "assistance_listing_number": "47.794",
          "program_title": "Dixon-Diaz"
        }
      ],
      "opportunity_id": 2,
      "opportunity_number": "ABC-2-XYZ-001",
      "opportunity_status": "forecasted",
      "opportunity_title": "Research into Animal technologist industry",
      "summary": {
        "additional_info_url": "grants.gov",
        "additional_info_url_description": "Click me for additional info",
        "agency_code": "US-XYZ",
        "agency_contact_description": "For more information contact us at - Policy mouth rule seem his. Tv surface after. Many affect pattern indicate.",
        "agency_email_address": "[email protected]",
        "agency_email_address_description": "Contact US Xylophone Yak Zoo via email",
        "agency_name": "US Xylophone Yak Zoo",
        "agency_phone_number": "123-456-0001",
        "applicant_eligibility_description": null,
        "applicant_types": [
          "city_or_township_governments",
          "special_district_governments",
          "independent_school_districts"
        ],
        "archive_date": "2024-04-03",
        "award_ceiling": 4485000,
        "award_floor": 448500,
        "close_date": null,
        "close_date_description": null,
        "estimated_total_program_funding": 4485000,
        "expected_number_of_awards": 10,
        "fiscal_year": 2025,
        "forecasted_award_date": "2024-09-19",
        "forecasted_close_date": "2024-04-30",
        "forecasted_close_date_description": "Air behind generation prepare responsibility.",
        "forecasted_post_date": "2024-03-24",
        "forecasted_project_start_date": "2025-01-30",
        "funding_categories": [
          "business_and_commerce",
          "arts"
        ],
        "funding_category_description": "Even visit drug reflect lead theory population others.",
        "funding_instruments": [
          "other"
        ],
        "is_cost_sharing": false,
        "is_forecast": true,
        "post_date": "2024-02-21",
        "summary_description": "Example summary - Business threat agree wish challenge. Brother send draw cell write other station."
      },
      "updated_at": "2024-03-07T16:48:01.576121+00:00"
    },
    {
      "agency": "US-123",
      "category": "continuation",
      "category_explanation": null,
      "created_at": "2024-03-07T16:48:01.637067+00:00",
      "opportunity_assistance_listings": [
        {
          "assistance_listing_number": "83.852",
          "program_title": "Smith Ltd"
        }
      ],
      "opportunity_id": 3,
      "opportunity_number": "ABC-3-XYZ-001",
      "opportunity_status": "forecasted",
      "opportunity_title": "Research into Accounting technician industry",
      "summary": {
        "additional_info_url": "google.com",
        "additional_info_url_description": "Click me for additional info",
        "agency_code": "US-123",
        "agency_contact_description": "For more information contact us at - Reason rise drug wrong. Nature poor end do.",
        "agency_email_address": "[email protected]",
        "agency_email_address_description": "Contact US Number Department via email",
        "agency_name": "US Number Department",
        "agency_phone_number": "123-456-0002",
        "applicant_eligibility_description": "Style must religious enough hear language. Report writer movement may risk agreement star. Center drug art either ten under American center. Main shoulder southern type popular girl. Care front model study soon economic often.",
        "applicant_types": [
          "federally_recognized_native_american_tribal_governments",
          "public_and_state_institutions_of_higher_education",
          "private_institutions_of_higher_education"
        ],
        "archive_date": "2024-04-01",
        "award_ceiling": 5325000,
        "award_floor": 591666,
        "close_date": null,
        "close_date_description": null,
        "estimated_total_program_funding": 5325000,
        "expected_number_of_awards": 9,
        "fiscal_year": 2025,
        "forecasted_award_date": "2024-09-18",
        "forecasted_close_date": "2024-05-13",
        "forecasted_close_date_description": "Process number writer take.",
        "forecasted_post_date": "2024-03-21",
        "forecasted_project_start_date": "2025-02-27",
        "funding_categories": [
          "disaster_prevention_and_relief",
          "community_development",
          "consumer_protection"
        ],
        "funding_category_description": null,
        "funding_instruments": [
          "cooperative_agreement"
        ],
        "is_cost_sharing": false,
        "is_forecast": true,
        "post_date": "2024-02-23",
        "summary_description": "Example summary - Possible yes future glass head better discuss pattern."
      },
      "updated_at": "2024-03-07T16:48:01.637067+00:00"
    }
  ],
  "message": "Success",
  "pagination_info": {
    "order_by": "opportunity_id",
    "page_offset": 1,
    "page_size": 3,
    "sort_direction": "ascending",
    "total_pages": 37,
    "total_records": 110
  },
  "status_code": 200,
  "warnings": []
}

)
factories.CurrentOpportunitySummaryFactory.create(
opportunity=all_null_opportunity, opportunity_summary=summary
)
Copy link
Contributor

@rylew1 rylew1 Mar 14, 2024

Choose a reason for hiding this comment

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

👍

"description": "Details regarding what modification was last made",
"example": None,
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be removed if they're not added back anywhere?

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 removed them from the model to avoid any confusion as the summary object has similar values. While I don't know what we want to do with these long-term, the current system returns the summary values, so I removed these in the top-level opportunity for now.

@@ -27,6 +27,8 @@ def search_opportunities(
# TODO - when we want to sort by non-opportunity table fields we'll need to change this
.order_by(sort_fn(getattr(Opportunity, search_params.pagination.order_by)))
.where(Opportunity.is_draft.is_(False)) # Only ever return non-drafts
# Filter anything without a current opportunity summary
.where(Opportunity.current_opportunity_summary != None) # noqa: E711
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it so we only pull opportunity records that have a summary when we make the request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Opportunities have to have a current opportunity summary (and thus an opportunity status which is that table) in order to be searchable. This is deliberate to avoid showing opportunities before their summaries, which are really the public notices of funding, are actually live/public.

Note this doesn't mean the opportunity is entirely hidden, if you navigate to the page of an opportunity directly, you would be able to find it.

@chouinar chouinar merged commit 79e0888 into main Mar 14, 2024
@chouinar chouinar deleted the chouinar/1364-update-api-schema branch March 14, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Adjust search API model to use the new schema & fields
3 participants