Code Monkey home page Code Monkey logo

message_in_a_bottle_backend's People

Contributors

justincanthony avatar marlitas avatar matt-kragen avatar tvaroglu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

message_in_a_bottle_backend's Issues

Update `Story` schema

Need to add the following columns to table:

  • title (CharField)
  • location (CharField)

Application Cleanup

  • The quickstart app name will be problematic for our endpoints, based on how Django builds routes. This needs to be renamed to api before we accrue any more technical debt
  • The Static Files directory that was auto-created floods the app with a bunch of additional JavaScript and CSS files that are not needed for the REST framework. We should remove these to slim down the infrastructure to what is actually needed for our purposes.

Create Killer ReadMe

  • Overall
  • Setup instructions
  • Collaborators
  • Tools used
  • Deployed page
  • Technologies used
  • How to use
  • Endpoints
  • Sample requests/responses
  • Special Thanks
  • Learning goals
  • Schema

README Examples

Create Initial Postman collection for endpoints

  • Create starter test collection for currently deployed endpoints
  • Create environment variable JSON files to dynamically toggle between dev vs prod during testing

Note, this will be an ongoing exercise as we add additional endpoints.

Final Application Cleanup Post-MVP

Final Cleanup Checklist:

  • Change radius back to 25 in MapService module:
    # services.py
    
        def get_stories(lat, long, stories):
            url = MapService.base_urls()['radius']
            params = {
                'key': MapService.api_key()
            }
            data = {
                'origin': {
                    'latLng': {
                        'lat': float(lat),
                        'lng': float(long)
                    }
                },
                'options': {
                    'maxMatches': 100,
                    'radius': 50,
                    'units': 'm'
                },
                'remoteDataList': stories
            }
            response = requests.post(url, params=params, data=json.dumps(data, indent=1))
            return response.json()
  • Clean up CORS_ALLOWED_ORIGINS in settings.py

Stories Index Error Handling

  • error handling for no stories in that radius
  • error handling for no lat & long provided
  • error handling for invalid lat & long provided

Final sweep of Postman collection

Placeholder issue to track any final test cleanup for Postman collection:

  • Correct env vars for Dev
  • Correct env vars for Prod
  • 100% passing suite with multiple runner iterations in both environments

Implement CI/CD

  • Deploy to Heroku
  • Configure CircleCI Builds
  • Configure CircleCI Automated Deploy:
    • Add Marla's API key to Circle ENV VARS
    • Change Heroku App Name and update Circle ENV VAR
    • Update local git remotes per new App Name

PATCH /api/v1/stories/<int:pk>

Endpoint to update a story within the database

Note: current placeholder is a PUT request (from following original tutorial), which will require a couple refactors:

  • Update CORS_ALLOWED_METHODS in settings.py
  • Update APIView method call in views.py to be a PATCH (vs PUT)

Divergence in API Issues

Justin has pulled down main and is able to view all stories that have been added in the last few days, regardless of the mileage from his house. My main (which references the same endpoint) is no longer able to view any of these stories. I am able to post and view my own stories still, but do not have access to any Justin posts. Justin's main does not have access to any stories I post.

Request:
Screen Shot 2021-10-23 at 9 00 54 PM
Response:
{"data":{"input_location":"This is a temporary location!","stories":[{"id":"91","type":"story","attributes":{"title":"This is a test","distance_in_miles":0,"latitude":40.337408,"longitude":-104.9460736}}]}}

The response is copy and pasted since the view screenshot on my dev tools cut half of it off. The response is only the story I posted while experimenting with this issue.

Configure CORS

  • Create 'test' endpoint GET /api/v1/test with a very basic response for testing CORS
  • Ensure allowed HTTP request methods permit fetch calls from FE are properly configured.

Resource

Validate Longitude and Latitude

  • Create a model validation:
    • -90 <= latitude <= 90
    • -180 <= longitude <= 180
    • must validate latitude and longitude fall within those ranges before saving to database or will break calls to Mapquest API
  • Reseed DB to remove invalid data

Refactor `StorySerializer` methods to make consistent use of `self` keyword

Half of the functions in StorySerializer pass self, and half don't. As a team, we should comb back through in our final refactoring to ensure consistency one way or the other.

Note, pycodestyle may help make the call on this for convention.. but based on my research, it's the most Pythonic way to always pass self as the first arg to any function

See Python docs:

Often, the first argument of a method is called self. This is nothing more than a convention: the name self has absolutely no special meaning to Python. Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a class browser program might be written that relies upon such a convention.

MapQuest Search Radius Config

  • Add API key to .env
  • Add API key as ENV VAR to CircleCI
  • Add API key as CONFIG VAR to Heroku
  • Add requests package to requirements.txt
  • Hit radius search endpoint
  • Test response values

Backfill Pytest request tests for deployed endpoints

  • GET /api/v1/stories/<int:pk>
  • POST /api/v1/stories
  • DELETE /api/v1/stores/<int:pk>

Currently using Postman to test our middleware, but we need to backfill request tests in pytest, so we can run the full suite inclusive of model and request specs.

Might be able to leverage the built in APIRequestFactory module from DRF

Additional resource

Clean Up ReadMe

  • Badges:

    • Update top level badges to reference the correct repo
    • Add Circle build badge
  • How to / Project Configs:

    • Ensure all references to Rails projects are removed
    • Ensure all steps taken to set up and configure project are clearly listed (reference BE Python Docs thread from Slack)
  • JSON contracts:

    • Double check request / response, query params, etc.
    • Add edge cases / sad paths
  • Database Schema:

    • Update screenshot

    [example link](Screen Shot 2021-10-25 at 12 16 45)

    See LucidChart for schema diagram

MapQuest Directions Endpoint

  • Create service method
  • Add model method to find applicable story in database
  • Hit directions endpoint
  • Test response values

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.