This is an API that connects to MapColonies geocoding service, and get's feedback from the users. Geocoding's feedback API collects usage data from the Geocoding API user's response and stores it for BI purposes. We use this data to better understand and measure the relevance of our responses and adjust the data and algorithm accordingly.
Checkout the OpenAPI spec here
Once a Geocoding user searches for something using Geocoding's api, it enters Redis, and an event is triggered. This event adds to the requestId (from geocoding) a prefix, and adds it also to Redis with a ttl.
When the Geocoding user chooses a result, the requesting system will then send the request_id, the chosen_response_id, and the user_id back to us using the Feedback api.
Once we get the chosen response from the api, we validate it and make sure it exists in the Redis, and once it is validated we add a wasUsed = true parameter to the geocoding response (in Redis) for later use. We then send the response to Kafka (where it will later be enriched and added to elastic -> see Geocoding Enrichment for more details).
Once the TTL of the requestId expires an even is triggered, and there are two options:
- One or more responses were chosen.
- No response was chosen (only searched for).
We now go back to the wasUsed parameter from earlier, and check to see its value (or even if it exists).
- If
wasUsed = truewe know from earlier that this response was already chosen and sent to Kafka previously, therefore we can remove it from the Redis geocoding DB index. - If
wasUsedequals to one of the following:false,nullorundefinedthen we create a new feedback response and make thechosenResultIdnull, and then send this response to Kafka, and delete the request from the Redis geocoding DB index.
Install deps with npm
npm installnpx husky installIn redis-cli
CONFIG SET notify-keyspace-events KEAClone the project
git clone https://github.com/MapColonies/feedback-api.git
Go to the project directory
cd feedback-api
Install dependencies
npm install
Start the server
npm run start
To run tests, run the following command
npm run test
To only run unit tests:
npm run test:unitTo only run integration tests:
npm run test:integration