Skip to content
Jupiter documentation
Menu

Keep search history

Connect Postgres to cache search results for an hour and log every search.

With DATABASE_URL set, the server caches each search result and logs each search in Postgres. Without it the server keeps no state between calls, and search_history returns db_disabled.

Steps#

  1. Set the connection string in .env.

  2. Start the server. At start it creates the schema procurement and the tables search_cache and search_log if they are missing.
  3. If the database role cannot create a schema, apply the migration once as a role that can, then grant the server's role access. The grants are at the end of the file, commented out.

  4. Call health and read database.

    When enabled is false, error holds the Postgres error. The server still runs and searches without the cache.

  5. Run a search, then call search_history.

Settings#

The migration file creates the schema procurement by name. If you set another PROCUREMENT_PG_SCHEMA, let the server create the tables, or edit the file.

What the cache key covers#

Two searches share a cached result when all of these match: query, query_zh, est_weight_kg, include_pickup, the marketplaces, sort, qty, the destination, max_results, ebay_auctions and ebay_seller_scope. deadline_s is left out of the key.

Errors#

Source: belikh/procurement HEAD