app/models/map_topic/topic_geo.rb
# as well as in corrections job, also called from MapTopic::LocationTopic.create_from_location
as well as in corrections job, also called from MapTopic::LocationTopic.create_from_location
as well as in corrections job also called from MapTopic :: LocationTopic . create_from_location
def add_or_update_place location, post_id
      unless (self.places.class == Hash) && (self.places['sorted_ids'])
        self.places = {
          'sorted_ids' => []
        }
        self.save!
      end
      location_id = location.id.to_s
      unless self.places['sorted_ids'].include? location_id
        self.places['sorted_ids'].push location_id
      end
      if self.places[location.id]
        post_ids = self.places[location.id]['post_ids'] || []
      else
        post_ids = []
      end
      if post_id
        post_ids.push post_id.to_s
      end
      place = {}
      place['title'] = location.title
      place['address'] = location.address
      place['gplace_id'] = location.gplace_id
      place['longitude'] = location.longitude
      place['latitude'] = location.latitude
      place['location_id'] = location_id
      place['detailsConfirmed'] = false
      place['post_ids'] = post_ids
      place['happenings'] = []
      self.places[location.id] = place
      self.save!
    end
def add_or_update_place location , post_id unless ( self . places . class == Hash ) && ( self . places [ 'sorted_ids' ] ) self . places = { 'sorted_ids' => [ ] } self . save! end location_id = location . id . to_s unless self . places [ 'sorted_ids' ] . include? location_id self . places [ 'sorted_ids' ] . push location_id end if self . places [ location . id ] post_ids = self . places [ location . id ] [ 'post_ids' ] || [ ] else post_ids = [ ] end if post_id post_ids . push post_id . to_s end place = { } place [ 'title' ] = location . title place [ 'address' ] = location . address place [ 'gplace_id' ] = location . gplace_id place [ 'longitude' ] = location . longitude place [ 'latitude' ] = location . latitude place [ 'location_id' ] = location_id place [ 'detailsConfirmed' ] = false place [ 'post_ids' ] = post_ids place [ 'happenings' ] = [ ] self . places [ location . id ] = place self . save! end
as well as in corrections job, also called from MapTopic::LocationTopic.create_from_location
as well as in corrections job also called from MapTopic :: LocationTopic . create_from_location
# the idea of having the place col is that it saves me having to query deeply for the basic info that I # will need to display a nice infowindow when showing index of topics... # below is a workaround check while I still have some places in db # that are arrays # binding.pry # should really make this the def value at db level # place = topic_places.select{ |p| p['location_id'] == location_id }[0] # unless place #   place = {} #   topic_places.push place # end # ensuring that there is always a happenings node on a place makes client side bindings work better.. # self.places[location.id.to_i] = place # the key always gets converted to a string on saving, even if I use to_i as above # in future, might store more in LocationTopic like happenings etc... # might get rid of LocationPosts...
location
<not_specific>
post_id
<not_specific>