Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Kategorien
- 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 }
- mig.each do |k,v|
- d = Definition.find k
- c = Category.find v
- c.explanations_de = d.explanation
- c.save!
- end
- 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 }
- def_offers = []
- hash.each do |k, v|
- d = Definition.find k
- c = Category.find v
- def_offers = d.offers.map(&:id).sort
- cat_offers = c.offers.map(&:id).sort
- offers_cat_missing = def_offers - cat_offers
- offers_cat_missing.each do |id|
- o = Offer.find id
- puts "saving category for offer #{id}"
- o.categories << c if c.sections.map(&:id).include?(o.section.id)
- o.save!
- end
- end
- sec_hash = { 7 => 700, 67 => 722, 95 => 723 }
- def_offers = []
- sec_hash.each do |k, v|
- d = Definition.find k
- c = Category.find v
- def_offers = d.offers.map(&:id).sort
- cat_offers = c.offers.map(&:id).sort
- offers_cat_missing = def_offers - cat_offers #find offers with definitions that don't have a category yet
- offers_cat_missing.each do |id|
- o = Offer.find id
- puts "saving category for offer #{id}"
- o.categories << c if c.sections.map(&:id).include?(o.section.id)
- o.save!
- end
- end
- Tags
- 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 }
- mig.each do |k,v|
- d = Definition.find k
- t = Tag.find v
- t.explanations_de = d.explanation
- t.save!
- end
- 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 }
- def_offers = []
- hash.each do |k,v|
- d = Definition.find k
- t = Tag.find v
- def_offers = d.offers.map(&:id).sort
- tag_offers = t.offers.map(&:id).sort
- offers_tag_missing = def_offers - tag_offers
- offers_tag_missing.each do |id|
- o = Offer.find id
- puts "saving tag for offer #{id}"
- o.tags << t
- o.save!
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement