Closed Fl4m3Ph03n1x closed 11 months ago
Arbiters of Hexis:
Cephalon Suda:
Steel Meridian:
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
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.