Table of Contents
Top Looks API
- Host: frontend05-hpc
- Run Environment: 2 Fast API Docker Containers (built from Fast API template) and an additional script
- Restart Command: compare TODO_restart on host
Short Description
The task of this API is to provide a fallback option if a look for a given shop is not complete. Then there should be the option to to show either the latest, or the most clicked look. The Top Looks API provides this functionality by returning (a dict of) a list of URLs of the top looks. There are some filter options described in Usage
Besides the Top Looks API which includes the endpoint to get these URLs, there exists a local database string the required information and another API + script to fill this database and update it. The data to fill the database is gathered from distributer.py
which pushes the billing data created by the Look API (v3).
The following image describes the connections between the single parts of Top Looks:
Top Looks API:
The main algorithm is located in app/top_look_id_getter.py
The main endpoint is located in app/routers/top_look.py
Top Looks Fill DB:
The main algorithm for filling the database and the endpoint are located in app/routers/fill_db.py
The main algorithm for completing the database entries is located in app/update_collections.py
Endpoints
- external endpoint to use the API (in TopLooksAPI):
/get_top_look
- internal endpoint (used by
distributer.py
in TopLooksFillDB):/in
Usage
- Fast API web interface: http://frontend05-hpc.picalike.corpex-kunden.de:8012/docs
I/O
Output:
- dictionary with list of IDs: {“look_ids”: [“id1”, “id2”, …]}
Input:
- shop_id (required): the shop_id (also called apikey sometimes) (example: Sportcheck: cGljc2ltaWxhcjozNDg2), the keys can be found at http://frontend03-hpc.picalike.corpex-kunden.de:3001/
- mode (required): “top” (to chose looks by number of calls) or “latest” (to get the newest looks)
- num_entries (optional) [default: 5]: specifies how many IDs should be returned
- gender (optional) [default: no filter]: filter by gender (as used by the shop) i.e. some shops use “Damen” others maybe “female” etc.
- last_n_days (optional) [default: all entries are used]: specify how many days back in time should be concidered if operating in mode “top”
Examples
- curl -X GET “http://frontend05-hpc.picalike.corpex-kunden.de:8012/get_top_look?shop_id=cGljc2ltaWxhcjo3MjMz&mode=latest&num_entries=5” -H “accept: application/json”
Data Storage
The data is stored in a local MongoDB: frontend05-hpc.picalike.corpex-kunden.de:27021 > top_looks_db
- Collection
looks
stores the data required for mode “latest” - Collection
count
stores the data required for mode “top”
Dependencies
distributer.py
(and in general the Look API and billing system)
Open ToDo's
- Should there be an expiring date for entries in count collection?
Update History
- 5.2.2020: Added Caching because of performance issues.
- 5.2.2020: Changed E-Mail service host in update_collections.py
- 5.2.2020: Improved the updating procedure (billing –> counts collection)