elif ad.feeds[0] not in e_ad.feeds: # If the ad is not listed as being in feeds we already know it # to be in, then ad the existing feed list to the new ad. Do # it this way so that we store the latest ad info just retrieved. ad.feeds += e_ad.feeds ads_to_put.append(ad) # EFFICIENCY: Technically, we need to update all UserCmt objects # which have a denormalized copy of this value too. However, # this would be mostly worthless since this new feed is probably # only used a single/few users - better to just do it on-demand. # (search view does this on-demand updating) elif ad.update_dt != e_ad.update_dt: # If the ad was updated but the feed is already present in the # existing ad entity's feeds ad.feeds = e_ad.feeds ads_to_put.append(ad) # else: the add hasn't changed => no need to send it to the datastore # create/update Ad entities if ads_to_put: db.put(ads_to_put) # update memcache entries which specify when a feed was last updated and the number of updated ads mc_dict = {'feed-update-dt:%s' % feed_key_name : now, 'feed-update-result:%s' % feed_key_name : len(ads_to_put) } memcache.set_multi(mc_dict) # update the Feed entity too feed.last_update = now