mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Profiler/Misc
* fix realm selection in profiler filters * minor cleanup of prQueue
This commit is contained in:
@@ -46,6 +46,8 @@ class ArenaTeamList extends BaseType
|
|||||||
|
|
||||||
class ArenaTeamListFilter extends Filter
|
class ArenaTeamListFilter extends Filter
|
||||||
{
|
{
|
||||||
|
use TrProfilerFilter;
|
||||||
|
|
||||||
public $extraOpts = [];
|
public $extraOpts = [];
|
||||||
protected $genericFilter = [];
|
protected $genericFilter = [];
|
||||||
|
|
||||||
@@ -86,33 +88,6 @@ class ArenaTeamListFilter extends Filter
|
|||||||
|
|
||||||
return $parts;
|
return $parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cbRegionCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
if (in_array($v, Util::$regions))
|
|
||||||
{
|
|
||||||
$this->parentCats[0] = $v; // directly redirect onto this region
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function cbServerCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
foreach (Profiler::getRealms() as $realm)
|
|
||||||
if ($realm['name'] == $v)
|
|
||||||
{
|
|
||||||
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -918,6 +918,37 @@ trait sourceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait TrProfilerFilter
|
||||||
|
{
|
||||||
|
protected function cbRegionCheck(string &$v) : bool
|
||||||
|
{
|
||||||
|
if (in_array($v, Util::$regions))
|
||||||
|
{
|
||||||
|
$this->parentCats[0] = $v; // directly redirect onto this region
|
||||||
|
$v = ''; // remove from filter
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function cbServerCheck(string &$v) : bool
|
||||||
|
{
|
||||||
|
foreach (Profiler::getRealms() as $realm)
|
||||||
|
{
|
||||||
|
if (Profiler::urlize($realm['name']) != $v)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$this->parentCats[1] = $v; // directly redirect onto this server
|
||||||
|
$v = ''; // remove from filter
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract class Filter
|
abstract class Filter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ class GuildList extends BaseType
|
|||||||
|
|
||||||
class GuildListFilter extends Filter
|
class GuildListFilter extends Filter
|
||||||
{
|
{
|
||||||
|
use TrProfilerFilter;
|
||||||
|
|
||||||
public $extraOpts = [];
|
public $extraOpts = [];
|
||||||
protected $genericFilter = [];
|
protected $genericFilter = [];
|
||||||
|
|
||||||
@@ -124,33 +126,6 @@ class GuildListFilter extends Filter
|
|||||||
|
|
||||||
return $parts;
|
return $parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cbRegionCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
if (in_array($v, Util::$regions))
|
|
||||||
{
|
|
||||||
$this->parentCats[0] = $v; // directly redirect onto this region
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function cbServerCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
foreach (Profiler::getRealms() as $realm)
|
|
||||||
if ($realm['name'] == $v)
|
|
||||||
{
|
|
||||||
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ class ProfileList extends BaseType
|
|||||||
|
|
||||||
class ProfileListFilter extends Filter
|
class ProfileListFilter extends Filter
|
||||||
{
|
{
|
||||||
|
use TrProfilerFilter;
|
||||||
|
|
||||||
public $useLocalList = false;
|
public $useLocalList = false;
|
||||||
public $extraOpts = [];
|
public $extraOpts = [];
|
||||||
|
|
||||||
@@ -359,33 +361,6 @@ class ProfileListFilter extends Filter
|
|||||||
return $parts;
|
return $parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cbRegionCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
if (in_array($v, Util::$regions))
|
|
||||||
{
|
|
||||||
$this->parentCats[0] = $v; // directly redirect onto this region
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function cbServerCheck(string &$v) : bool
|
|
||||||
{
|
|
||||||
foreach (Profiler::getRealms() as $realm)
|
|
||||||
if ($realm['name'] == $v)
|
|
||||||
{
|
|
||||||
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
|
|
||||||
$v = ''; // remove from filter
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function cbProfession(int $cr, int $crs, string $crv, $skillId) : ?array
|
protected function cbProfession(int $cr, int $crs, string $crv, $skillId) : ?array
|
||||||
{
|
{
|
||||||
if (!Util::checkNumeric($crv, NUM_CAST_INT) || !$this->int2Op($crs))
|
if (!Util::checkNumeric($crv, NUM_CAST_INT) || !$this->int2Op($crs))
|
||||||
|
|||||||
31
prQueue
31
prQueue
@@ -29,17 +29,16 @@ CLI::write('profiler queue started', CLI::LOG_OK);
|
|||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
$tCycle = microtime(true);
|
$tCycle = microtime(true);
|
||||||
|
|
||||||
$error = function ($type, $realmGUID, $realmId)
|
$error = function (int $type, int $realmGUID, int $realmId) : void
|
||||||
{
|
{
|
||||||
$what = '';
|
$what = match ($type)
|
||||||
if ($type == Type::PROFILE)
|
{
|
||||||
$what = 'char';
|
Type::PROFILE => 'char',
|
||||||
if ($type == Type::GUILD)
|
Type::GUILD => 'guild',
|
||||||
$what = 'guild';
|
Type::ARENA_TEAM => 'arena team'
|
||||||
if ($type == Type::ARENA_TEAM)
|
};
|
||||||
$what = 'arena team';
|
|
||||||
|
|
||||||
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = ?d WHERE realm = ?d AND realmGUID = ?d AND type = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_CHAR, $realmId, $realmGUID, $type);
|
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = ?d WHERE `realm` = ?d AND `realmGUID` = ?d AND `type` = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_CHAR, $realmId, $realmGUID, $type);
|
||||||
trigger_error('prQueue - '.$what.' #'.$realmGUID.' on realm #'.$realmId.' not found. Truncating local placeholder.', E_USER_WARNING);
|
trigger_error('prQueue - '.$what.' #'.$realmGUID.' on realm #'.$realmId.' not found. Truncating local placeholder.', E_USER_WARNING);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
usleep($wait * 1000 * 1000);
|
usleep($wait * 1000 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = DB::Aowow()->selectRow('SELECT * FROM ?_profiler_sync WHERE status = ?d ORDER BY requestTime ASC', PR_QUEUE_STATUS_WAITING);
|
$row = DB::Aowow()->selectRow('SELECT * FROM ?_profiler_sync WHERE `status` = ?d ORDER BY `requestTime` ASC', PR_QUEUE_STATUS_WAITING);
|
||||||
if (!$row)
|
if (!$row)
|
||||||
{
|
{
|
||||||
// nothing more to do
|
// nothing more to do
|
||||||
@@ -68,12 +67,12 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
|
|
||||||
if (empty(Profiler::getRealms()[$row['realm']]))
|
if (empty(Profiler::getRealms()[$row['realm']]))
|
||||||
{
|
{
|
||||||
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = ?d WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_ARMORY, $row['realm'], $row['type'], $row['typeId']);
|
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = ?d WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_ARMORY, $row['realm'], $row['type'], $row['typeId']);
|
||||||
CLI::write('realm #'.$row['realm'].' for subject guid '.$row['realmGUID'].' is undefined', CLI::LOG_WARN);
|
CLI::write('realm #'.$row['realm'].' for subject guid '.$row['realmGUID'].' is undefined', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_WORKING, $row['realm'], $row['type'], $row['typeId']);
|
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_WORKING, $row['realm'], $row['type'], $row['typeId']);
|
||||||
|
|
||||||
switch ($row['type'])
|
switch ($row['type'])
|
||||||
{
|
{
|
||||||
@@ -81,7 +80,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
if (!Profiler::getCharFromRealm($row['realm'], $row['realmGUID']))
|
if (!Profiler::getCharFromRealm($row['realm'], $row['realmGUID']))
|
||||||
{
|
{
|
||||||
$error(Type::PROFILE, $row['realmGUID'], $row['realm']);
|
$error(Type::PROFILE, $row['realmGUID'], $row['realm']);
|
||||||
DB::Aowow()->query('DELETE FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
|
DB::Aowow()->query('DELETE FROM ?_profiler_profiles WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
if (!Profiler::getGuildFromRealm($row['realm'], $row['realmGUID']))
|
if (!Profiler::getGuildFromRealm($row['realm'], $row['realmGUID']))
|
||||||
{
|
{
|
||||||
$error(Type::GUILD, $row['realmGUID'], $row['realm']);
|
$error(Type::GUILD, $row['realmGUID'], $row['realm']);
|
||||||
DB::Aowow()->query('DELETE FROM ?_profiler_guild WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
|
DB::Aowow()->query('DELETE FROM ?_profiler_guild WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
if (!Profiler::getArenaTeamFromRealm($row['realm'], $row['realmGUID']))
|
if (!Profiler::getArenaTeamFromRealm($row['realm'], $row['realmGUID']))
|
||||||
{
|
{
|
||||||
$error(Type::ARENA_TEAM, $row['realmGUID'], $row['realm']);
|
$error(Type::ARENA_TEAM, $row['realmGUID'], $row['realm']);
|
||||||
DB::Aowow()->query('DELETE FROM ?_profiler_arena_team WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
|
DB::Aowow()->query('DELETE FROM ?_profiler_arena_team WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +111,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
|
|||||||
$tCycle = microtime(true);
|
$tCycle = microtime(true);
|
||||||
|
|
||||||
// mark as ready
|
// mark as ready
|
||||||
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = 0 WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_READY, $row['realm'], $row['type'], $row['typeId']);
|
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = 0 WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_READY, $row['realm'], $row['type'], $row['typeId']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler::queueFree();
|
Profiler::queueFree();
|
||||||
|
|||||||
Reference in New Issue
Block a user