Skip to content

Commit

Permalink
killId as Index
Browse files Browse the repository at this point in the history
  • Loading branch information
ppetermann committed Dec 17, 2012
1 parent 1ea16d3 commit c663a64
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
18 changes: 11 additions & 7 deletions src/Kingboard/Lib/Parser/EveAPI.php
Expand Up @@ -54,6 +54,9 @@ public function parseKill($kill)

// the kill needs some additional data

// convert killId to int
$killdata['killId'] = (int) $killdata['killId'];

// location data
$killdata['location'] = array(
"solarSystem" => EveSolarSystem::getBySolarSystemId($kill['solarSystemID'])->itemName,
Expand Down Expand Up @@ -179,14 +182,15 @@ public function ensureEveEntityID($id, $charname)
{
if($id = \Kingboard\Model\MapReduce\NameSearch::getEveIdByName($charname))
return $id;

$pheal = new Pheal();
$result = $pheal->eveScope->typeName(array('names' => $charname))->toArray();
if ((int) $result[0]['characterID'] > 0)
return (int) $result[0]['characterID'];

if(!empty($charname))
{
$pheal = new Pheal();
$result = $pheal->eveScope->typeName(array('names' => $charname))->toArray();
if ((int) $result[0]['characterID'] > 0)
return (int) $result[0]['characterID'];
}
throw new \Exception("No such characterID");
}
return $id;
}
}
}
4 changes: 2 additions & 2 deletions tasks/Kingboard/KingboardCronTask.php
Expand Up @@ -93,7 +93,7 @@ public function api_import(array $options)
try {
$stats = \Kingboard\Lib\Fetcher\EveApi::fetch($key);
$this->cli->message("processed key $keyid for user " . $user->name . " : ". $stats['old'] . ' known / ' . $stats['new'] ." new");
} catch(\PhealException $e) {
} catch(\Exception $e) {
// we caught a pheal exception, we should implement proper handling of errors here
$this->cli->error("key $keyid caused pheal exception: " . $e->getMessage());
}
Expand Down Expand Up @@ -127,4 +127,4 @@ public function item_values(array $options)
$this->cli->message("Did not update ".$item->typeID.", it had a value of 0");
}
}
}
}
4 changes: 2 additions & 2 deletions tasks/Kingboard/KingboardMaintenanceTask.php
Expand Up @@ -119,7 +119,7 @@ public function setup_indexes(array $options)
// location.solarSystem
$col->ensureIndex(array('location.solarSystem' => 1), array("name" => "systemname"));

$col->ensureIndex(array('killID' =>1), array("name" => "killid"));
$col->ensureIndex(array('killId' =>1), array("name" => "killid", "unique" => true, "dropDups" => true));

$col->ensureIndex(array('totalISKValue' => -1), array("name" => "iskvalue"));

Expand All @@ -146,4 +146,4 @@ public function setup_indexes(array $options)


}
}
}
15 changes: 9 additions & 6 deletions tasks/Kingboard/KingboardTask.php
Expand Up @@ -47,12 +47,15 @@ public function process_stomp_queue(array $options)
$stomp->ack($frame);
continue;
}
try {
$apiParser = new EveAPI();
$apiParser->parseKill($killdata);

$apiParser = new EveAPI();
$apiParser->parseKill($killdata);

$this->cli->message($frame->headers['message-id'] .'::' . $killdata["killID"] . " saved");
$stomp->ack($frame);
$this->cli->message($frame->headers['message-id'] .'::' . $killdata["killID"] . " saved");
$stomp->ack($frame);
} catch(\Exception $e) {
$this->cli->error($frame->headers['message-id'] . "could not be saved, exception: " . $e->getMessage());
}
}
}

Expand All @@ -63,4 +66,4 @@ public function test(array $options)
{
}

}
}

0 comments on commit c663a64

Please sign in to comment.