
Courtoisie
BORE DOME
0
|
Posted - 2015.10.27 16:39:52 -
[1] - Quote
I am working with Steve's github code, and was wondering if someone could help me get unstuck.
In my google spreadsheet, I have a column of TypeIDs, some of which repeat. Steve's code seems to ignore repetitions. if there any way of changing the code to not do this? Here is the code:
function loadSystemPrices(priceIDs,systemID,cachebuster){ if (typeof systemID == 'undefined'){ systemID=30000142; } if (typeof priceIDs == 'undefined'){ throw 'need typeids'; } if (typeof cachebuster == 'undefined'){ cachebuster=1; } var prices = new Array(); var dirtyTypeIds = new Array(); var cleanTypeIds = new Array(); var url="http://api.eve-central.com/api/marketstat?cachebuster="+cachebuster+"&usesystem="+systemID+"&typeid="; priceIDs.forEach (function (row) { row.forEach ( function (cell) { if (typeof(cell) === 'number' ) { dirtyTypeIds.push(cell); } }); }); cleanTypeIds = dirtyTypeIds.filter(function(v,i,a) { return a.indexOf(v)===i; }); var parameters = {method : "get", payload : ""}; var o,j,temparray,chunk = 100; for (o=0,j=cleanTypeIds.length; o < j; o+=chunk) { temparray = cleanTypeIds.slice(o,o+chunk); var xmlFeed = UrlFetchApp.fetch(url+temparray.join("&typeid="), parameters).getContentText(); var xml = XmlService.parse(xmlFeed); if(xml) { var rows=xml.getRootElement().getChild("marketstat").getChildren("type"); for(var i = 0; i < rows.length; i++) { var price=[parseFloat(rows[i].getChild("buy").getChild("max").getValue()), parseFloat(rows[i].getChild("sell").getChild("min").getValue())]; prices.push(price); } } } return prices; }
I am thinking if may have something to do with the section:
priceIDs.forEach (function (row) { row.forEach ( function (cell) { if (typeof(cell) === 'number' ) { dirtyTypeIds.push(cell); |

Steve Ronuken
Fuzzwork Enterprises Vote Steve Ronuken for CSM
5689
|
Posted - 2015.10.27 21:43:22 -
[2] - Quote
It explicitly ignores repetition, yes.
Because what you should be doing with it, is loading all the price data into a separate sheet, then using vlookup to pull the bits you want out.
That way, you're not asking eve central for the same data multiple times. Just neighbourly, really.
Woo! CSM X!
Fuzzwork Enterprises
Twitter: @fuzzysteve on Twitter
|