Skip to content

MapColonies/feedback-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feedback-Api

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.

API

Checkout the OpenAPI spec here

Workflow

workflow img

How does it work?

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:

  1. One or more responses were chosen.
  2. 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 = true we 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 wasUsed equals to one of the following: false, null or undefined then we create a new feedback response and make the chosenResultId null, and then send this response to Kafka, and delete the request from the Redis geocoding DB index.

Installation

Install deps with npm

npm install

Install Git Hooks

npx husky install

Make sure you have keyspace notifications in Redis

In redis-cli

CONFIG SET notify-keyspace-events KEA

Run Locally

Clone 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

Running Tests

To run tests, run the following command

npm run test

To only run unit tests:

npm run test:unit

To only run integration tests:

npm run test:integration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •