User Tools

Site Tools


top_looks_api

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:

dokuwiki_lib_exe_fetch.php_w_600_tok_d9bc34_media_20191127_122836.jpg

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

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

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

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)
top_looks_api.txt · Last modified: 2024/04/11 14:23 by 127.0.0.1