Fl4m3Ph03n1x / market_manager

Makes requests in bulk to warframe market
0 stars 1 forks source link

Add products for all syndicates #87

Closed Fl4m3Ph03n1x closed 11 months ago

Fl4m3Ph03n1x commented 1 year ago

Currently I have quite a list of syndicates, but some of them are empty. Users dont like this. I need to feel the products list for each syndicate I have in the list.

Fl4m3Ph03n1x commented 11 months ago

Arbiters of Hexis:

Fl4m3Ph03n1x commented 11 months ago

Cephalon Suda:

Fl4m3Ph03n1x commented 11 months ago

Steel Meridian:

Fl4m3Ph03n1x commented 11 months ago

Script used to find product matches:

From within web_interface:

item_names = File.read!("INPUT.txt") |> String.split("\r\n") |> Enum.map(&String.trim/1)
products = File.read!("../store/priv/products.json") |> Jason.decode!()

match_products = fn item_names, products ->  
  Enum.map(item_names, fn name -> 
    products 
    |> Enum.find(fn product -> product |> Map.get("name") |> String.downcase() == String.downcase(name) end) 
    |> case do
        nil -> [name, nil]
        r -> [name, Map.get(r, "id")]
      end
    end)
end

File.write!("OUTPUT.json", Jason.encode!(match_products.(item_names, products)))

To check current syndicates:

products = File.read!("../store/priv/products.json") |> Jason.decode!()

syndicate_mod_names = fn id, syndicates, products -> 
  syndicates
  |> Enum.find(fn syn -> Map.get(syn, "id") == id end) 
  |> Map.get("catalog")
  |> Enum.map(fn mod_id -> Enum.find(products, fn p -> Map.get(p, "id") == mod_id end) |> Map.get("name") end) 
end