diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-29 10:16:55 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-05-13 18:36:22 +0300 |
commit | 39489d14493d7fb8832b5ff1dccdd74aeaeb69af (patch) | |
tree | 8781ed6854e46f7cb76464e8d8d5e8063e2e4cd4 /lib/Migration | |
parent | 238f030b264b7b02a64f65582114c8ee7a449c91 (diff) |
Add a ML-based classifier for important messages
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Migration')
-rw-r--r-- | lib/Migration/FixBackgroundJobs.php (renamed from lib/Migration/FixAccountSyncs.php) | 8 | ||||
-rw-r--r-- | lib/Migration/Version1040Date20200506111214.php | 88 |
2 files changed, 92 insertions, 4 deletions
diff --git a/lib/Migration/FixAccountSyncs.php b/lib/Migration/FixBackgroundJobs.php index ba2166e85..5775684c4 100644 --- a/lib/Migration/FixAccountSyncs.php +++ b/lib/Migration/FixBackgroundJobs.php @@ -26,13 +26,14 @@ declare(strict_types=1); namespace OCA\Mail\Migration; use OCA\Mail\BackgroundJob\SyncJob; +use OCA\Mail\BackgroundJob\TrainImportanceClassifierJob; use OCA\Mail\Db\MailAccount; use OCA\Mail\Db\MailAccountMapper; use OCP\BackgroundJob\IJobList; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -class FixAccountSyncs implements IRepairStep { +class FixBackgroundJobs implements IRepairStep { /** @var IJobList */ private $jobList; @@ -45,7 +46,7 @@ class FixAccountSyncs implements IRepairStep { } public function getName(): string { - return 'Insert sync background job for all accounts'; + return 'Insert background jobs for all accounts'; } public function run(IOutput $output) { @@ -53,12 +54,11 @@ class FixAccountSyncs implements IRepairStep { $accounts = $this->mapper->getAllAccounts(); $output->startProgress(count($accounts)); - foreach ($accounts as $account) { $this->jobList->add(SyncJob::class, ['accountId' => $account->getId()]); + $this->jobList->add(TrainImportanceClassifierJob::class, ['accountId' => $account->getId()]); $output->advance(); } - $output->finishProgress(); } } diff --git a/lib/Migration/Version1040Date20200506111214.php b/lib/Migration/Version1040Date20200506111214.php new file mode 100644 index 000000000..5f19ab931 --- /dev/null +++ b/lib/Migration/Version1040Date20200506111214.php @@ -0,0 +1,88 @@ +<?php + +declare(strict_types=1); + +namespace OCA\Mail\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version1040Date20200506111214 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * + * @return ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->createTable('mail_classifiers'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 20, + ]); + $table->addColumn('account_id', 'integer', [ + 'notnull' => true, + 'length' => 20, + ]); + $table->addColumn('type', 'string', [ + 'notnull' => true, + 'length' => 255, + ]); + $table->addColumn('estimator', 'string', [ + 'notnull' => true, + 'length' => 255, + ]); + $table->addColumn('app_version', 'string', [ + 'notnull' => true, + 'length' => 31, + ]); + $table->addColumn('training_set_size', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('validation_set_size', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('recall_important', 'decimal', [ + 'notnull' => true, + 'precision' => 10, + 'scale' => 5, + ]); + $table->addColumn('precision_important', 'decimal', [ + 'notnull' => true, + 'precision' => 10, + 'scale' => 5, + ]); + $table->addColumn('f1_score_important', 'decimal', [ + 'notnull' => true, + 'precision' => 10, + 'scale' => 5, + ]); + $table->addColumn('duration', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('active', 'boolean', [ + 'notnull' => true, + 'default' => false, + ]); + $table->addColumn('created_at', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + + $table->setPrimaryKey(['id']); + $table->addIndex(['account_id', 'type'], 'mail_clssfr_accnt_id_type'); + + return $schema; + } +} |