[fix] Statistics

This commit is contained in:
Lkeme 2020-06-28 11:27:01 +08:00
parent 746d75cf89
commit 83d5adeb86
2 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,9 @@ class Competition
{ {
use TimeLock; use TimeLock;
/**
* @use 赛事入口 https://www.bilibili.com/v/game/match/competition
*/
public static function run() public static function run()
{ {
if (getenv('USE_COMPETITION') == 'false' || self::getLock() > time()) { if (getenv('USE_COMPETITION') == 'false' || self::getLock() > time()) {
@ -37,10 +40,9 @@ class Competition
$questions = self::fetchQuestions(); $questions = self::fetchQuestions();
$max_guess = intval(getenv('COMPET_MAX_NUM')); $max_guess = intval(getenv('COMPET_MAX_NUM'));
foreach ($questions as $index => $question) { foreach ($questions as $index => $question) {
if (($index + 1) >= $max_guess) { if ($index >= $max_guess) {
break; break;
} }
// int $, int $main_id, int $detail_id, int $coin_num
$guess = self::parseQuestion($question); $guess = self::parseQuestion($question);
self::addGuess($guess); self::addGuess($guess);
} }

View File

@ -169,7 +169,7 @@ class Statistics
$results = 0; $results = 0;
is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key); is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key);
foreach ($target as $item) { foreach ($target as $item) {
$skip = is_null($second_key) ? isset($item[$key]) : $item[$key][$second_key]; $skip = is_null($second_key) ? isset($item[$key]) : isset($item[$key][$second_key]);
if ($skip) { if ($skip) {
is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]); is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]);
} }