Skip to content

Conversation

@loganripplinger
Copy link
Contributor

@loganripplinger loganripplinger commented Nov 19, 2019

Overview

This adds the ability to reverse query a relationship.

Previously you were only able to query /credentials/programs but this allows you to also query /programs/credentials.

Checklist

  • PR has a descriptive enough title to be useful in changelogs

Notes

In this solution I use _asdict() which may be problematic down the road. Relevant stackoverflow -- https://stackoverflow.com/questions/1958219/convert-sqlalchemy-row-object-to-python-dict

Testing Instructions

  • Start after checking out this branch.
  • To be safe ensure you have killed any running docker images related to Data Resource API.
  • Create the data resource and run it with;
docker build -t brighthive/data-resource-api:1.0.0-alpha .
docker-compose up
  • Allow the data resource to initialize for a minute or two. You may see errors occur at first.
  • Open POSTMAN.
  • Create two credentials by performing a POST to http://localhost:8000/credentials with the following JSON body:
{
	"credential_name": "credential test"
}
  • Create a program with two credentials by performing a POST to http://localhost:8000/programs with the following JSON body:
{
	"program_name": "aprogram 1",
	"program_code": 1,
	"program_description": ".",
	"program_status": ".",
	"program_fees": 1,
	"eligibility_criteria": ".",
	"program_url": ".",
	"credentials": [1,2]
}
  • Get the data by performing GET http://localhost:8000/credentials/1/programs

  • You should see

{
    "programs": [
        1
    ]
}

handles #6

@loganripplinger loganripplinger marked this pull request as ready for review November 19, 2019 22:28
@loganripplinger loganripplinger merged commit ad3ee0e into master Nov 19, 2019
@loganripplinger loganripplinger deleted the feat/reverse-many-to-many branch December 2, 2019 17:47
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.

2 participants