 # .each(function(i, v) { console.log($(v).attr('href')) });
 
 baseUri = 'http://www.thegoodscentscompany.com'
-pageCodes = [
-  'a'
-  'b'
-  'c'
-  'd'
-  'e'
-  'f'
-  'g'
-  'h'
-  'i'
-  'jk'
-  'l'
-  'm'
-  'n'
-  'o'
-  'p'
-  'q'
-  'r'
-  's'
-  't'
-  'u'
-  'v'
-  'wx'
-  'y'
-  'z'
-]
 
 pageQueue = queues.create
-  totalRequests: pageCodes.length
   loadFactor: 4
   delay: 250
 
-componentQueue = queues.create
+ingredientQueue = queues.create
   loadFactor: 20
   delay: 500
 
-fetchPage = (code) ->
+fetchPage = (uri) ->
   fetched = p.defer()
 
   pageQueue.queue ->
-    request "#{baseUri}/flonly-#{code}.htm"
+    request uri
     .then (doc) ->
       $ = cheerio.load doc
 


  fetched.promise

fetchDetails = (component, componentCount) ->
  fetched = p.defer()

  componentQueue.totalRequests = componentCount
  componentQueue.queue ->
    request "#{baseUri}/data/#{component.id}.html"
    .then (doc) ->
      $ = cheerio.load doc
      console.log "parsing details for #{component.name}"

      # try and parse the label for this row into a hashable key
      data = {}

        name: $('td.prodname').text().trim()
        notes: $('.fotq').text().trim()
        synonyms: $('#rhtable tr[itemscope]').map(mapSynonyms).get()
        demoUri: $('.demstrafrm').find('a').attr('href').trim()
        data: data

      fetched.resolve merge(ingredient, details)
    .catch (err) -> fetched.reject err

  fetched.promise
