/** * @test */ public function getModeFromAnArray() { $numbers = array(3, 3, 6, 8, 2, 9, 2, 1, 7, 6, 5, 1, 4, 2, 3, 5, 8, 11, 1, 8, 5, 2, 2, 7, 8, 11, 10, 8, 7); $this->assertEquals(array(2, 8), $this->statistic->getMode($numbers)); array_push($numbers, 8); $this->assertEquals(array(8), $this->statistic->getMode($numbers)); $numbers = array(1, 2, 3, 4, 5, 9, 8, 7, 0, 11); $this->assertEquals(0, count($this->statistic->getMode($numbers))); }
public function router($cmd0, $cmd1, $cmd2, $player_id, $arr_param) { global $arrParam, $arrAuthUser, $logHandler; $arrAuthUser['player_id'] = $player_id; $arrParam = $arr_param; $class = 'S2P_' . $cmd1; $include_file = ACTION_PATH . "/S2P/S2P_{$cmd1}.php"; if (is_file($include_file)) { require $include_file; try { //调用对应指令函数 $obj = new $class(); $exec_cmd2 = 'CMD2_' . $cmd2; if (ECONOMY_LOG_SWITCH === TRUE) { $logHandler['logger'] = new Com_Logger($cmd0, $cmd1, $cmd2, $player_id); } call_user_func_array(array($obj, $exec_cmd2), array()); $protocols = Protocol::get_protocol(); Protocol::out(); Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 1, 'exec fun success', $protocols); if (ECONOMY_LOG_SWITCH === TRUE) { $logHandler['logger']->flush_log(); } exit; } catch (Exception $e) { //有异常 $msg = json_decode($e->getMessage(), true); $error = "Exception: " . $e->getFile() . " line:" . $e->getLine() . " error code " . $msg['error']['code']; Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 0, $error); Protocol::input($player_id, 8, 7, 742, array(0 => array($msg['error']))); Protocol::out(); exit; } } }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Statistic::create([]); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Statistic the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Statistic::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function statistic() { $qq = count(User::where('qq_id', '!=', 'null')->get()); $weixin = count(User::where('unionid', '!=', 'null')->get()); $s = Statistic::find(1); if (isset($s)) { $s->qq = $qq; $s->weixin = $weixin; $s->save(); } else { $s = new Statistic(); $s->qq = $qq; $s->weixin = $weixin; $s->save(); } return true; }
public function actionStatistics() { $criteria = new CDbCriteria(); $criteria->limit = 4; $criteria->order = 'date DESC'; $criteria->condition = 'id_user='******'statistics', array('model' => $model)); }
public function getMongoCommand() { $commands = array(); $map = new MongoCode("\n function() {\n var date = ISODate(this.dateCreate);\n var key = {departureCityId: this.departureCityId, arrivalCityId: this.arrivalCityId };\n emit(key, {count: 1});\n };\n "); $reduce = new MongoCode("function(key, values) {\n var sum = 0;\n values.forEach(function(value) {\n sum += value['count'];\n });\n return {count: sum};\n };\n "); $finalize = new MongoCode("function (key, value) {\n return value['count']\n }"); $commands['mapreduce1'] = array("mapreduce" => Statistic::model()->getCollectionName(), "map" => $map, "reduce" => $reduce, "finalize" => $finalize, "query" => array("modelName" => "FlightSearch"), "out" => $this->result->getCollectionName()); return $commands; }
public function graph() { $data = []; $data['data_for_graph']['videos'] = Statistic::getDataForGraph('Video'); $data['data_for_graph']['users'] = Statistic::getDataForGraph('User', 'reg_timestamp'); $data['data_for_graph']['videos_year'] = Statistic::getDataForGraph('Video', 'timestamp', 3600 * 24 * 30 * 12, 3600 * 24 * 30, "Y-m"); $data['data_for_graph']['users_year'] = Statistic::getDataForGraph('User', 'reg_timestamp', 3600 * 24 * 30 * 12, 3600 * 24 * 30, "Y-m"); return new ViewResponse('admin/statistic/graph', $data); }
public function getMongoCommand() { $commands = array(); $map = new MongoCode("\r\n function() {\r\n var date = ISODate(this.dateCreate);\r\n var key = {date: date, searchId: this.searchId};\r\n emit(key, {count: 1});\r\n };\r\n "); $reduce = new MongoCode("function(key, values) {\r\n var sum = 0;\r\n values.forEach(function(value) {\r\n sum += value['count'];\r\n });\r\n return {count: sum};\r\n };\r\n "); $commands['mapreduce1'] = array("mapreduce" => Statistic::model()->getCollectionName(), "map" => $map, "reduce" => $reduce, "query" => array("modelName" => "FlightSearch"), "out" => $this->result->getCollectionName()); $map = new MongoCode("\r\n function() {\r\n var key = {year: this._id['date'].getFullYear(), month: this._id['date'].getMonth()+1, day: this._id['date'].getDate()};\r\n emit(key, {count: 1});\r\n };\r\n "); $commands['mapreduce2'] = array("mapreduce" => $this->result->getCollectionName(), "map" => $map, "reduce" => $reduce, "out" => $this->result->getCollectionName()); return $commands; }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-runs"); parent::SetTitle("Most runs"); parent::SetColumnHeaders(array("Runs")); parent::SetDescription("Find out who has scored the most runs overall in all stoolball matches."); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("bowling-performances"); parent::SetTitle("All bowling performances"); parent::SetDescription("See the best wicket-taking performances in all stoolball matches."); parent::SetSupportsFilterByPlayer(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("innings"); parent::SetItemTypePlural("innings"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-wickets-by-bowler-and-catcher"); parent::SetTitle("Most wickets by a bowling and catching combination"); parent::SetDescription("This measures which combination of bowler and catcher has taken the most wickets. Catches taken by a bowler off their own bowling are not counted."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("combination"); parent::SetItemTypePlural("combinations"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("player-performances"); parent::SetTitle("Player performances"); parent::SetDescription("All of the match performances by a stoolball player, summarising their batting, bowling and fielding in the match."); parent::SetSupportsFilterByPlayer(true); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("performance"); parent::SetItemTypePlural("performances"); }
public static function saveStatistic($model, $event) { $model_events = config('quickcms.model_events'); foreach ($model_events as $model_event) { if ($model->getTable() == $model_event['table'] && $model_event['event'] == $event && (array_key_exists('where', $model_event) ? $model->{$model_event}['where']['column'] == $model_event['where']['value'] : true)) { $statistic = Statistic::select('id', 'statistic_value')->where('statistic_key', $model_event['statistic_key'])->whereRaw("statistic_time=date_format(now(),'%Y-%m-%d')")->first(); $statistic_value = $model_event['statistic_value'] == 1 ? 1 : $model->{$model_event}['statistic_value']; if (!isset($statistic)) { $statistic = new Statistic(); $statistic->statistic_value += $statistic_value; $statistic->sort = $model_event['sort']; $statistic->statistic_time = date('Y-m-d', time()); $statistic->statistic_key = $model_event['statistic_key']; $statistic->save(); } else { $statistic->statistic_value += $statistic_value; $statistic->save(); } } } }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-player-of-match"); parent::SetTitle("Most player of the match nominations"); parent::SetColumnHeaders(array("Nominations")); parent::SetDescription("Find out who has won the most player of the match awards for their outstanding performances on the pitch."); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("player-of-match"); parent::SetTitle("Player of the match nominations"); parent::SetDescription("All of the matches where players were awarded player of the match for their outstanding performances on the pitch."); parent::SetSupportsFilterByPlayer(true); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("nomination"); parent::SetItemTypePlural("nominations"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("individual-scores"); parent::SetTitle("Highest individual scores"); parent::SetDescription("See the highest scores by individuals in a single stoolball innings."); parent::SetSupportsFilterByPlayer(true); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("innings"); parent::SetItemTypePlural("innings"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-run-outs"); parent::SetTitle("Most run-outs"); parent::SetColumnHeaders(array("Run-outs")); parent::SetDescription("This measures the number of run-outs completed by a fielder, not how often a batsman has been run-out."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); parent::SetCssClass("bowling"); }
public function __construct($minimum_qualifying_score, StatisticsManager $statistics_data_source) { $this->minimum_qualifying_score = (int) $minimum_qualifying_score; $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-scores-of"); parent::SetTitle("Most scores of {$minimum_qualifying_score} or more runs"); parent::SetColumnHeaders(array("Innings")); parent::SetDescription("Find out who has played the most innings of {$minimum_qualifying_score} runs or more in all stoolball matches."); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("batting-average"); parent::SetTitle("Batting averages"); parent::SetDescription("A batsman's average measures how many runs he or she typically scores before getting out. We only include people who have batted at least three times, and got out at least once."); parent::SetShowDescription(true); parent::SetColumnHeaders(array("Average")); parent::SetSupportsFilterByBattingPosition(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); }
public function __construct($minimum_qualifying_wickets, \StatisticsManager $statistics_data_source) { $this->minimum_qualifying_wickets = (int) $minimum_qualifying_wickets; $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-{0}-wickets"); parent::SetTitle("Most times taking {$minimum_qualifying_wickets} wickets in an innings"); parent::SetColumnHeaders(array("Innings")); parent::SetDescription("Find out who has taken {$minimum_qualifying_wickets} wickets in an innings the most times in all stoolball matches."); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-wickets"); parent::SetTitle("Most wickets"); parent::SetColumnHeaders(array("Wickets")); parent::SetDescription("If a player is out caught, caught and bowled, bowled, body before wicket or for hitting the ball twice the wicket is credited to the bowler and included here. Players run-out or timed out are not counted."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("most-catches-in-innings"); parent::SetTitle("Most catches in an innings"); parent::SetColumnHeaders(array("Catches")); parent::SetDescription("This measures the number of catches taken by a fielder, not how often a batsman has been caught out. We only include players who took at least three catches."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("innings"); parent::SetItemTypePlural("innings"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("bowling-strike-rate"); parent::SetTitle("Bowling strike rates"); parent::SetColumnHeaders(array("Strike rate")); parent::SetDescription("A bowler's strike rate measures how many deliveries he or she typically bowls before taking a wicket. Lower numbers are better.\r\n \r\nWe only include people who have bowled in at least three matches, and we ignore wickets in innings where the bowling card wasn't filled in."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); parent::SetCssClass("bowling"); }
public function __construct(StatisticsManager $statistics_data_source) { $this->statistics_data_source = $statistics_data_source; parent::SetUrlSegment("economy-rate"); parent::SetTitle("Economy rates"); parent::SetColumnHeaders(array("Economy rate")); parent::SetDescription("A bowler's economy rate measures how many runs he or she typically concedes in each over. Lower numbers are better. We only include people who have bowled in at least three matches."); parent::SetShowDescription(true); parent::SetSupportsPagedResults(true); parent::SetItemTypeSingular("player"); parent::SetItemTypePlural("players"); parent::SetCssClass("bowling"); }
public function getStatus() { switch ($this->is_active) { case Referals::$NOT_ACTIVE: $txt = "Не активирован"; break; case Referals::$ACTIVE: $statistic = Statistic::model()->findByAttributes(array('id_player' => $this->id_referal)); $txt = "Активирован" . ", внес в систему: " . $statistic->invest_summ . ' руб.'; break; } return $txt; }
/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $user = User::model()->find('LOWER(login)=?', array(strtolower($this->username))); if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($user !== null && $user->password !== $this->hashPassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $user->id_user; Statistic::writeStat($this->_id); $this->username = $user->firstname; $this->errorCode = self::ERROR_NONE; } return !$this->errorCode; }
public static function getStock($warehouseId, $cartonId = null, $categoryId = null, $paletteId = null, $locationId = null, $male = null, $female = null, $children = null, $baby = null, $summer = null, $winter = null, $showEmpty = false) { if ($warehouseId) { if ($cartonId) { return Statistic::getCartonStock($warehouseId, $cartonId); } else { if ($paletteId) { return Statistic::getPaletteStock($warehouseId, $paletteId); } else { if ($locationId) { return Statistic::getLocationStock($warehouseId, $locationId); } else { if ($categoryId) { return Statistic::getCategoryStock($warehouseId, $categoryId); } else { return Statistic::getWarehouseStock($warehouseId); } } } } } }
/** * Если пользователь зарегистрировался и сохранился то возвращаем //тру * * @return boolean */ public function checkAndLoginNewplayer() { if ($this->validate()) { // Если пароли не совпадают выдадим ошибку if ($this->password != $this->password_repeat) { $this->addError('password', 'Вы указали разные значения в поле пароль'); return false; } else { $this->password = md5($this->password); $this->date_regist = time(); if ($this->save()) { // Отправить письмо с подтверждением email $this->sendAndCheckEmail(); // Проверка и создание реферала $session = new CHttpSession(); $session->open(); if (isset($session['ref_id'])) { $player = Player::model()->findByAttributes(array('id' => (int) $session['ref_id'])); if ($player != null) { $referal = new Referals(); $referal->id_player = $player->id; $referal->id_referal = $this->id; $referal->is_active = Referals::$NOT_ACTIVE; $referal->save(); } } $statistic = new Statistic(); $statistic->id_player = $this->id; $statistic->invest_summ = 0; $statistic->out_sum = 0; $statistic->questions_summ_complette = 0; $statistic->referals = 0; $statistic->save(); $identity = new UserIdentity($this->email, $this->password); $identity->authenticate(); Yii::app()->user->login($identity, 0); return true; } else { return false; } } } else { return false; } }
function statistics_get() { if (!$this->get('type')) { $this->response(NULL, 400); } $statistics = new Statistic(); $statistics->order_by('number', 'asc')->get_by_type($this->get('type')); $scenario_options = array('played_most', 'played_least', 'season', 'evergreen'); $person_options = array('player_complete_pfs', 'player_complete_core', 'gm_complete_pfs', 'gm_complete_core'); $result = array(); foreach ($statistics as $statistic) { $result[$statistic->id] = $statistic->to_array(); if (in_array($this->get('type'), $person_options)) { $result[$statistic->id]['person'] = $statistic->person->to_array(); } else { $result[$statistic->id]['scenario'] = $statistic->scenario->to_array(); } } $this->response($result, 200); }