data-skeptic/dataskeptic.com

Poll component on homepage.

Opened this issue · 0 comments

We are going to have a new homepage design as shown in #733.

This ticket is all about the implementation of these designs:

poll_of_the_week
poll 2

The web application will interact with our API to complete all the requests. All requests should be sent to the server via /api/v1/poll/** for example, while developing, it would be localhost:3000/api/v1/poll/** but the same code in production would call dataskeptic.com/api/v1/poll/**.

This /api should just proxy the requests to the actual API which is on a different server. For this Issue, you will not work on the API. Consider the API to be a 3rd party service which you will consume. If you find any bugs or problems with the API, communicate them to Kyle.

You should proxy one request to get the poll from this address (GET):
https://4sevcujref.execute-api.us-east-1.amazonaws.com/dev/poll?poll_id=-1&user_id=-1

Let me explain the use of -1. When you provide poll_id=-1, it will give you the latest poll, which is what you want to display. This way, you don't have to know what the poll_id is. If the user is not logged in, send user_id=-1. If the user is logged in, this will be used to provide their previous vote (if they have one).

You should vote for the poll via this endpoint (POST):
https://4sevcujref.execute-api.us-east-1.amazonaws.com/dev/poll/vote
Sending:

{"poll_id": 12345, "user_id": 123456, "question_id": 42, "choice_id": 411}