/**
  * run the map/reduce
  * @static
  * @return void
  */
 public static function mapReduce()
 {
     $map = "function () {\r\n            if(arguments.callee.shipcache === undefined)\r\n            {\r\n                arguments.callee.shipcache = {}\r\n            }\r\n            if(arguments.callee.shipcache[this.victim.shipTypeID] === undefined)\r\n            {\r\n                arguments.callee.shipcache[this.victim.shipTypeID] = db.Kingboard_EveItem.findOne({typeID: parseInt(this.victim.shipTypeID)},{'marketGroup.parentGroup.marketGroupName':1});\r\n            }\r\n            var ship = arguments.callee.shipcache[this.victim.shipTypeID];\r\n            var info = {}\r\n            info[this.victim.shipType] = 1;\r\n            info[\"total\"] = 1;\r\n            if(ship != null && ship.marketGroup != null)\r\n                emit(ship.marketGroup.parentGroup.marketGroupName, info);\r\n        }";
     $reduce = "function (k, vals) {\r\n            var sums = {}\r\n            var total = 0;\r\n            vals.forEach(function(info) {\r\n                info[\"total\"] = 0;\r\n                for (var key in info)\r\n                {\r\n                    if(sums[key] === undefined)\r\n                        sums[key] = 0;\r\n                    sums[key] += info[key];\r\n                    total += info[key];\r\n                }\r\n            });\r\n            sums[\"total\"] = total;\r\n            return sums;\r\n        }";
     // we want the map/reduce to run for as long as it takes
     MongoCursor::$timeout = -1;
     return King23_Mongo::mapReduce("Kingboard_Kill", __CLASS__, $map, $reduce);
 }
 /**
  * run the map/reduce
  * @static
  * @return array
  */
 public static function mapReduce($filter)
 {
     $map = "function () {\n            var ship = db.Kingboard_EveItem.findOne({typeID: parseInt(this.victim.shipTypeID)},{'marketGroup.parentGroup.marketGroupName':1});\n            var info = {}\n            info[this.victim.shipType] = 1;\n            info[\"total\"] = 1;\n            if(ship != null && ship.marketGroup != null)\n                emit(ship.marketGroup.parentGroup.marketGroupName, info);\n        }";
     $reduce = "function (k, vals) {\n            var sums = {}\n            var total = 0;\n            vals.forEach(function(info) {\n                info[\"total\"] = 0;\n                for (var key in info)\n                {\n                    if(sums[key] === undefined)\n                        sums[key] = 0;\n                    sums[key] += info[key];\n                    total += info[key];\n                }\n            });\n            sums[\"total\"] = total;\n            return sums;\n        }";
     return King23_Mongo::cachedMapReduce(__CLASS__, 120, "Kingboard_Kill", $map, $reduce, $filter);
 }