Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated collector to only insert the required properties into mongodb

  • Loading branch information...
commit 25d1310dbb2b96a7957381b043bce24609fdd91d 1 parent f90a79a
Michael Hughes authored
View
5 src/server/collector/bulkcollector.coffee
@@ -1,6 +1,7 @@
xml2js = require 'xml2js'
http = require 'http'
mongostore = require '../mongostore.coffee'
+_ = require 'underscore'
#example url:
# http://www.brickset.com/webservices/brickset.asmx/search?apiKey=&userHash=&query=&theme=&subtheme=&year=&owned=&wanted=&setNumber=10030-1
@@ -28,7 +29,9 @@ exports.createBulkCollector = (connectionString, urlGenerator)->
parser = new xml2js.Parser()
parser.parseString data, (err,result)->
throw err if err
- fun(err,result?.ArrayOfSetData.setData[0])
+ set = _.pick result?.ArrayOfSetData.setData[0],
+ 'number','setName','year','theme','subtheme','pieces','minifigs','thumbnailURL'
+ fun(err,set)
collectSets:(listOfSetNumbers,fun,current=0,listOfResults=[])->
if listOfSetNumbers.length <= current then fun(null,listOfResults)
View
5 test/server/collector/bulkcollector_test.coffee
@@ -12,7 +12,6 @@ describe 'A bulk collector', ->
fs.readFile __dirname + '/resources/test.xml','utf8', (err, data)=>
throw err if err
@bc.parseXml data,(err,result)->
- result.setID.should.eql(["1"])
result.setName.should.eql(["Test set"])
done()
it 'should be able to retrieve and parse some XML', (done)->
@@ -23,6 +22,10 @@ describe 'A bulk collector', ->
@bc.setInformation "test",(err,result)->
result.theme.should.eql(["Test theme"])
done()
+ it 'should only pull certain properties from the XML', (done)->
+ @bc.setInformation "test",(err,result)->
+ should.not.exist result.instructionsAvailable
+ done()
it 'should be able to generate a url to brickset',->
bulkcollector.url("10030").should.equal("http://www.brickset.com/webservices/brickset.asmx/search?apiKey=&userHash=&query=&theme=&subtheme=&year=&owned=&wanted=&setNumber=10030-1")
it 'should be able to retrieve a set by sending in an array',(done)->
Please sign in to comment.
Something went wrong with that request. Please try again.