-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch histogram algo for X Power distrib
- Loading branch information
1 parent
286a9f2
commit 9b4ba3b
Showing
12 changed files
with
310 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) 2015-2023 AIZAWA Hina | ||
* @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT | ||
* @author AIZAWA Hina <hina@fetus.jp> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use app\components\db\Migration; | ||
use app\components\helpers\TypeHelper; | ||
use yii\db\Connection; | ||
use yii\db\Expression; | ||
|
||
final class m231115_115658_xpower_distrib_histogram extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$db = TypeHelper::instanceOf($this->db, Connection::class); | ||
|
||
$this->addColumns('{{%stat_x_power_distrib_abstract3}}', [ | ||
'histogram_width' => $this->integer()->null(), | ||
]); | ||
|
||
$this->update( | ||
'{{%stat_x_power_distrib_abstract3}}', | ||
[ | ||
'histogram_width' => new Expression( | ||
vsprintf('HISTOGRAM_WIDTH(%s, %s::NUMERIC)', [ | ||
$db->quoteColumnName('users'), | ||
$db->quoteColumnName('stddev'), | ||
]), | ||
), | ||
], | ||
); | ||
|
||
$this->createTable('{{%stat_x_power_distrib_histogram3}}', [ | ||
'season_id' => $this->pkRef('{{%season3}}')->notNull(), | ||
'rule_id' => $this->pkRef('{{%rule3}}')->notNull(), | ||
'class_value' => $this->integer()->notNull(), | ||
'users' => $this->bigInteger()->notNull(), | ||
'PRIMARY KEY ([[season_id]], [[rule_id]], [[class_value]])', | ||
]); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
$this->dropTable('{{%stat_x_power_distrib_histogram3}}'); | ||
$this->dropColumn('{{%stat_x_power_distrib_abstract3}}', 'histogram_width'); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function vacuumTables(): array | ||
{ | ||
return [ | ||
'{{%stat_x_power_distrib_abstract3}}', | ||
'{{%stat_x_power_distrib_histogram3}}', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) 2015-2023 AIZAWA Hina | ||
* @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT | ||
* @author AIZAWA Hina <hina@fetus.jp> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace app\models; | ||
|
||
use yii\db\ActiveQuery; | ||
use yii\db\ActiveRecord; | ||
|
||
/** | ||
* This is the model class for table "stat_x_power_distrib_histogram3". | ||
* | ||
* @property integer $season_id | ||
* @property integer $rule_id | ||
* @property integer $class_value | ||
* @property integer $users | ||
* | ||
* @property Rule3 $rule | ||
* @property Season3 $season | ||
*/ | ||
class StatXPowerDistribHistogram3 extends ActiveRecord | ||
{ | ||
public static function tableName() | ||
{ | ||
return 'stat_x_power_distrib_histogram3'; | ||
} | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
[['season_id', 'rule_id', 'class_value', 'users'], 'required'], | ||
[['season_id', 'rule_id', 'class_value', 'users'], 'default', 'value' => null], | ||
[['season_id', 'rule_id', 'class_value', 'users'], 'integer'], | ||
[['season_id', 'rule_id', 'class_value'], 'unique', 'targetAttribute' => ['season_id', 'rule_id', 'class_value']], | ||
[['rule_id'], 'exist', 'skipOnError' => true, 'targetClass' => Rule3::class, 'targetAttribute' => ['rule_id' => 'id']], | ||
[['season_id'], 'exist', 'skipOnError' => true, 'targetClass' => Season3::class, 'targetAttribute' => ['season_id' => 'id']], | ||
]; | ||
} | ||
|
||
public function attributeLabels() | ||
{ | ||
return [ | ||
'season_id' => 'Season ID', | ||
'rule_id' => 'Rule ID', | ||
'class_value' => 'Class Value', | ||
'users' => 'Users', | ||
]; | ||
} | ||
|
||
public function getRule(): ActiveQuery | ||
{ | ||
return $this->hasOne(Rule3::class, ['id' => 'rule_id']); | ||
} | ||
|
||
public function getSeason(): ActiveQuery | ||
{ | ||
return $this->hasOne(Season3::class, ['id' => 'season_id']); | ||
} | ||
} |
Oops, something went wrong.