Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mapping = {
- "American" => ["American Fusion","American Sea food","Beef Burger","Burgers","Burger","Gourmet Burger","Gourmet Sliders","Fried Chicken","Southern","Steak","Tex Mex"],
- "Arabic" => ["Arabian","Arabic Grills","Arabic Sweets","Bahraini","Bahraini Food","Egyptian Food","Egyptian","Lebanese","Emirati","Falafel","Kuwaiti","Koshary","Manakeesh","Manakish","Iraqi","Jordanian","Palestinian","Qatari","Shami","Syrian","Yemeni","Bedouin"],
- "Asian" => ["Chinese","Indian","Thai","Vietnamese","Indian Food","Indian Taste","Japanese","Japanese Taste","Oriental","Pakistani","Korean","Modern Indian","Modern Asian","Philippines","Phillipino","Sushi"],
- "Bakery" => ["Bread","Pastries","Pastry"],
- "Beverages" => ["Cocktails","Cold Drinks","Drinks","Milkshakes","Juices","Karak"],
- "Coffee" => ["Latte","Coffee Roasters","Specialty Coffee"],
- "Desserts" => ["Cupcakes","Cupcakes","Crepes","Crepe","Cookies","Candy","Cake","Cakes","Lugimat","Kunafah","Baklava","Pie","Sweets","Waffle","Chocolate","Ice Cream","Frozen Yogurt","Yogurt"],
- "European" => ["Armenian","Azerbaijan","Belarusian","Bulgarian","Georgian","Kazakh","Moldovan","Romanian","Russian","Ukrainian","British","Danish","Estonian","Faroese","Finnish","Icelandic","Irish","Latvian","Lithuanian","Norwegian","Swedish","Belgian","Dutch"],
- "Latin American" => ["Argentina","Brazilian","Mexican","Peruvian"],
- "Mediterranean" => ["French","Greek","Spanish","Algeria","Libya","Tunisia","Morocco","Portuguese"],
- "Middle Eastern" => ["Moroccan","Persian","Iranian","Afghani","Armenian"],
- "Italian" => ["Neapolitan", "Pasta"],
- "Healthy" => ["Healthy Food","Diet Restaurant"],
- "Vegan" => "Vegan Cafe",
- "Turkish" => "Doner",
- "Seafood" => "Fish"
- }
- Country.set_country_attr 1
- mapping.map do |k, v|
- old_ids = Cousin.where(name: v).pluck(:id)
- p old_ids
- if old_ids.present?
- new_cousin = Cousin.where(name: k, country_id: Country.country_id_cache).first_or_create
- CousinsLocation.unscoped.where(cousin_id: old_ids).update_all(cousin_id: new_cousin.id)
- Cousin.where(id: old_ids).update_all(active: false)
- new_cousin.update_attributes(active: true)
- end
- end
- to_be_added = ["Fast Food","Pizza","Salads","Sandwiches","Shawerma & Doner","African"]
- removed_cousins = Cousin.filter_by_vertical(1).where(active: true).pluck(:name) - (mapping.keys + to_be_added)
- Cousin.where(name: removed_cousins).update_all(active: false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement