/**
  *
  */
 public function testFind()
 {
     if (extension_loaded('xdebug')) {
         $this->assertTrue(true);
         return;
     }
     $gameVersion = 'tw';
     $pool = PdoFactory::makePool($gameVersion);
     $uidList = [474000, 474001, 474002];
     $provider = new UserDetailProvider($gameVersion, $pool);
     $payload = array_filter($provider->find($uidList));
     $foundUidList = [];
     foreach ($payload as $shardId => $userList) {
         static::assertStringStartsWith('db', $shardId);
         $foundUidList = array_merge($foundUidList, array_keys($userList));
         foreach ($userList as $user) {
             static::assertTrue(is_array($user));
             static::assertArrayHasKey('uid', $user);
             static::assertArrayHasKey('snsid', $user);
             static::assertArrayHasKey('history_pay_amount', $user);
         }
     }
     sort($uidList);
     sort($foundUidList);
     static::assertEquals($uidList, $foundUidList);
 }
예제 #2
0
$options = getopt('v', ['gv:', 'es:', 'uid:']);
$verbose = isset($options['v']);
$gameVersion = null;
if (defined('GAME_VERSION')) {
    $gameVersion = GAME_VERSION;
} else {
    assert(isset($options['gv']), 'game version not defined');
    $gameVersion = trim($options['gv']);
}
$esHost = isset($options['es']) ? $options['es'] : '52.19.73.190';
assert(isset($options['uid']), 'uid not defined');
$uid = trim($options['uid']);
$msg = sprintf('game version: %s, ES host: %s, uid: %s', $gameVersion, $esHost, $uid);
$verbose && dump($msg);
$provider = new UserDetailProvider($gameVersion, PdoFactory::makePool($gameVersion));
$groupedUserList = array_filter($provider->find([$uid]));
if ($verbose) {
    dump(__FILE__);
    dump($groupedUserList);
}
$indexer = IndexerFactory::make($esHost, $gameVersion);
foreach ($groupedUserList as $shardId => $shardUserList) {
    $delta = $indexer->batchUpdate($shardUserList);
    $batchResult = $indexer->getBatchResult();
    dump(__FILE__);
    array_map(function ($errorString) {
        $decoded = json_decode($errorString, true);
        if (is_array($decoded)) {
            dump($decoded);
        } else {
            dump($errorString);