These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Steve's Github code

First post
Author
Courtoisie
Doomheim
#1 - 2015-10-27 16:39:52 UTC  |  Edited by: Courtoisie
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
#2 - 2015-10-27 21:43:22 UTC
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 XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

For-You
The Cadre Arareb Foundation
#3 - 2015-10-28 17:34:32 UTC
Steve Ronuken wrote:
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.


Thanks!