Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. Kategorien
  2. mig = { 149 => 681, 150 => 683, 151 => 543, 96 => 453, 189 => 532, 97 => 462, 132 => 721, 37 => 909, 177 => 633, 130 => 468, 78 => 653, 137 => 813 }
  3.  
  4. mig.each do |k,v|
  5. d = Definition.find k
  6. c = Category.find v
  7. c.explanations_de = d.explanation
  8. c.save!
  9. end
  10.  
  11. hash = { 148 => 634, 149 => 681, 150 => 683, 151 => 543, 96 => 453, 22 => 398, 189 => 532, 97 => 462, 132 => 721, 37 => 909, 177 => 633, 61 => 457, 110 => 382, 112 => 591, 118 => 394, 136 => 383, 130 => 468, 78 => 653, 137 => 813, 7 => 658, 67 => 529, 95 => 686 }
  12.  
  13. def_offers = []
  14. hash.each do |k, v|
  15. d = Definition.find k
  16. c = Category.find v
  17. def_offers = d.offers.map(&:id).sort
  18. cat_offers = c.offers.map(&:id).sort
  19. offers_cat_missing = def_offers - cat_offers
  20. offers_cat_missing.each do |id|
  21. o = Offer.find id
  22. puts "saving category for offer #{id}"
  23. o.categories << c if c.sections.map(&:id).include?(o.section.id)
  24. o.save!
  25. end
  26. end
  27.  
  28. sec_hash = { 7 => 700, 67 => 722, 95 => 723 }
  29.  
  30. def_offers = []
  31. sec_hash.each do |k, v|
  32. d = Definition.find k
  33. c = Category.find v
  34. def_offers = d.offers.map(&:id).sort
  35. cat_offers = c.offers.map(&:id).sort
  36. offers_cat_missing = def_offers - cat_offers #find offers with definitions that don't have a category yet
  37. offers_cat_missing.each do |id|
  38. o = Offer.find id
  39. puts "saving category for offer #{id}"
  40. o.categories << c if c.sections.map(&:id).include?(o.section.id)
  41. o.save!
  42. end
  43. end
  44.  
  45.  
  46. Tags
  47. mig = { 82 => 9, 191 => 11, 162 => 37, 54 => 40, 56 => 47, 178 => 53, 33 => 55, 159 => 61, 164 => 63, 144 => 98, 111 => 140, 63 => 141, 152 => 159, 190 => 178, 194 => 186, 161 => 187, 74 => 188, 165 => 190, 176 => 191, 206 => 193, 123 => 207 }
  48.  
  49. mig.each do |k,v|
  50. d = Definition.find k
  51. t = Tag.find v
  52. t.explanations_de = d.explanation
  53. t.save!
  54. end
  55.  
  56. hash = { 82 => 9, 85 => 10, 191 => 11, 88 => 21, 6 => 28, 92 => 31, 162 => 37, 54 => 40, 55 => 43, 205 => 46, 56 => 47, 57 => 50, 178 => 53, 33 => 55, 159 => 61, 164 => 63, 163 => 73, 207 => 68, 142 => 82, 195 => 185, 102 => 90, 144 => 98, 48 => 109, 106 => 115, 127 => 122, 186 => 137, 111 => 140, 63 => 141, 114 => 149, 187 => 152, 66 => 154, 152 => 159, 116 => 151, 160 => 168, 117 => 170, 70 => 174, 190 => 178, 194 => 186, 161 => 187, 74 => 188, 165 => 190, 176 => 191, 122 => 192, 206 => 193, 76 => 196, 183 => 205, 123 => 207, 175 => 210 }
  57.  
  58. def_offers = []
  59. hash.each do |k,v|
  60. d = Definition.find k
  61. t = Tag.find v
  62. def_offers = d.offers.map(&:id).sort
  63. tag_offers = t.offers.map(&:id).sort
  64. offers_tag_missing = def_offers - tag_offers
  65. offers_tag_missing.each do |id|
  66. o = Offer.find id
  67. puts "saving tag for offer #{id}"
  68. o.tags << t
  69. o.save!
  70. end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement