Module: OutriderTools::Link

Defined in:
lib/outrider/tools.rb

Class Method Summary collapse

Class Method Details

.save_many(links, project, log) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/outrider/tools.rb', line 111

def self.save_many( links, project, log )
  
  unless links.nil? 
    links.each  do |link|
      # Check if link already exists
      #if ProjectData.find_by(url: link.to_s).nil?
      unless ProjectData.where( url: link.to_s, project_id: project[:id] ).exists?  
        ProjectData.create({
          :url        => link.to_s,
          :status     => 'unscraped',
          :project_id => project[:id]
        })
        log.info "Adding new url to database: #{link.to_s}"
      else
        log.info "URL already exists in database: #{link.to_s}"
      end
    end
  end
  
  
end