From 764fadcd37a8038857d39023ff21a11f5ba82dea Mon Sep 17 00:00:00 2001 From: Jeremy Postlethwaite Date: Fri, 26 Apr 2024 21:55:27 -0700 Subject: [PATCH] GH-19 --- database/factories/BoardFactory.php | 4 +- database/factories/SprintFactory.php | 4 +- ...02_100001_create_matrix_backlogs_table.php | 18 +-- ...1_02_100001_create_matrix_boards_table.php | 31 +++-- ..._02_100001_create_matrix_sprints_table.php | 29 ++-- ..._02_100001_create_matrix_tickets_table.php | 4 +- src/Models/Backlog.php | 49 ++++++- src/Models/Board.php | 130 +++++++++++++++++- src/Models/Sprint.php | 130 +++++++++++++++++- src/Models/Ticket.php | 14 +- tests/Feature/Models/Backlog/ModelTest.php | 13 ++ tests/Feature/Models/Board/ModelTest.php | 5 + tests/Feature/Models/Sprint/ModelTest.php | 5 + tests/Feature/Models/Ticket/ModelTest.php | 10 ++ 14 files changed, 391 insertions(+), 55 deletions(-) diff --git a/database/factories/BoardFactory.php b/database/factories/BoardFactory.php index daa4e27..35f7130 100644 --- a/database/factories/BoardFactory.php +++ b/database/factories/BoardFactory.php @@ -1,9 +1,9 @@ bigInteger('x')->nullable(); $table->bigInteger('y')->nullable(); $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); + $table->decimal('r', 65, 10)->nullable(); + $table->decimal('theta', 10, 6)->nullable(); + $table->decimal('rho', 10, 6)->nullable(); + $table->decimal('phi', 10, 6)->nullable(); + $table->decimal('elevation', 65, 10)->nullable(); + $table->decimal('latitude', 8, 6)->nullable(); + $table->decimal('longitude', 9, 6)->nullable(); // Flags @@ -130,7 +130,7 @@ public function up(): void $table->string('label')->default(''); $table->string('title')->default(''); $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); + $table->string('slug')->nullable()->index(); $table->string('url')->default(''); $table->string('description')->default(''); $table->string('introduction')->default(''); diff --git a/database/migrations/2020_01_02_100001_create_matrix_boards_table.php b/database/migrations/2020_01_02_100001_create_matrix_boards_table.php index a3c3c17..df72ee8 100644 --- a/database/migrations/2020_01_02_100001_create_matrix_boards_table.php +++ b/database/migrations/2020_01_02_100001_create_matrix_boards_table.php @@ -1,15 +1,18 @@ uuid('id')->primary(); @@ -28,8 +32,8 @@ public function up(): void $table->uuid('modified_by_id')->nullable()->index(); $table->uuid('owned_by_id')->nullable()->index(); $table->uuid('parent_id')->nullable()->index(); - $table->string('board_type')->nullable()->index(); $table->uuid('backlog_id')->nullable()->index(); + $table->string('board_type')->nullable()->index(); $table->uuid('epic_id')->nullable()->index(); $table->uuid('flow_id')->nullable()->index(); $table->uuid('matrix_id')->nullable()->index(); @@ -89,13 +93,13 @@ public function up(): void $table->bigInteger('x')->nullable(); $table->bigInteger('y')->nullable(); $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); + $table->decimal('r', 65, 10)->nullable(); + $table->decimal('theta', 10, 6)->nullable(); + $table->decimal('rho', 10, 6)->nullable(); + $table->decimal('phi', 10, 6)->nullable(); + $table->decimal('elevation', 65, 10)->nullable(); + $table->decimal('latitude', 8, 6)->nullable(); + $table->decimal('longitude', 9, 6)->nullable(); // Flags @@ -103,6 +107,7 @@ public function up(): void $table->boolean('canceled')->default(0); $table->boolean('closed')->default(0); $table->boolean('completed')->default(0); + $table->boolean('cron')->default(0)->index(); $table->boolean('duplicate')->default(0); $table->boolean('fixed')->default(0); $table->boolean('flagged')->default(0); @@ -118,19 +123,19 @@ public function up(): void $table->boolean('suspended')->default(0); $table->boolean('unknown')->default(0); - // Strings + // Columns $table->string('label')->default(''); $table->string('title')->default(''); $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); + $table->string('slug')->nullable()->index(); $table->string('url')->default(''); $table->string('description')->default(''); $table->string('introduction')->default(''); $table->mediumText('content')->nullable(); $table->mediumText('summary')->nullable(); - // UI + // Ui $table->string('icon')->default(''); $table->string('image')->default(''); diff --git a/database/migrations/2020_01_02_100001_create_matrix_sprints_table.php b/database/migrations/2020_01_02_100001_create_matrix_sprints_table.php index b48645c..00129ae 100644 --- a/database/migrations/2020_01_02_100001_create_matrix_sprints_table.php +++ b/database/migrations/2020_01_02_100001_create_matrix_sprints_table.php @@ -1,15 +1,18 @@ uuid('id')->primary(); @@ -89,13 +93,13 @@ public function up(): void $table->bigInteger('x')->nullable(); $table->bigInteger('y')->nullable(); $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); + $table->decimal('r', 65, 10)->nullable(); + $table->decimal('theta', 10, 6)->nullable(); + $table->decimal('rho', 10, 6)->nullable(); + $table->decimal('phi', 10, 6)->nullable(); + $table->decimal('elevation', 65, 10)->nullable(); + $table->decimal('latitude', 8, 6)->nullable(); + $table->decimal('longitude', 9, 6)->nullable(); // Flags @@ -103,6 +107,7 @@ public function up(): void $table->boolean('canceled')->default(0); $table->boolean('closed')->default(0); $table->boolean('completed')->default(0); + $table->boolean('cron')->default(0)->index(); $table->boolean('duplicate')->default(0); $table->boolean('fixed')->default(0); $table->boolean('flagged')->default(0); @@ -118,19 +123,19 @@ public function up(): void $table->boolean('suspended')->default(0); $table->boolean('unknown')->default(0); - // Strings + // Columns $table->string('label')->default(''); $table->string('title')->default(''); $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); + $table->string('slug')->nullable()->index(); $table->string('url')->default(''); $table->string('description')->default(''); $table->string('introduction')->default(''); $table->mediumText('content')->nullable(); $table->mediumText('summary')->nullable(); - // UI + // Ui $table->string('icon')->default(''); $table->string('image')->default(''); diff --git a/database/migrations/2020_01_02_100001_create_matrix_tickets_table.php b/database/migrations/2020_01_02_100001_create_matrix_tickets_table.php index 640cdec..f8e761f 100644 --- a/database/migrations/2020_01_02_100001_create_matrix_tickets_table.php +++ b/database/migrations/2020_01_02_100001_create_matrix_tickets_table.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Schema; /** - * Playground\Matrix\Models\Ticket + * \Playground\Matrix\Models\Ticket */ return new class() extends Migration { @@ -112,6 +112,7 @@ public function up(): void $table->boolean('canceled')->default(0); $table->boolean('closed')->default(0); $table->boolean('completed')->default(0); + $table->boolean('cron')->default(0)->index(); $table->boolean('duplicate')->default(0); $table->boolean('fixed')->default(0); $table->boolean('flagged')->default(0); @@ -128,7 +129,6 @@ public function up(): void $table->boolean('special')->default(0); $table->boolean('suspended')->default(0); $table->boolean('unknown')->default(0); - $table->boolean('cron')->default(0)->index(); // Columns diff --git a/src/Models/Backlog.php b/src/Models/Backlog.php index 07d3353..9ffb370 100644 --- a/src/Models/Backlog.php +++ b/src/Models/Backlog.php @@ -175,6 +175,17 @@ class Backlog extends Model 'status' => 0, 'rank' => 0, 'size' => 0, + 'matrix' => '{}', + 'x' => null, + 'y' => null, + 'z' => null, + 'r' => null, + 'theta' => null, + 'rho' => null, + 'phi' => null, + 'elevation' => null, + 'latitude' => null, + 'longitude' => null, 'active' => true, 'canceled' => false, 'closed' => false, @@ -267,6 +278,17 @@ class Backlog extends Model 'status', 'rank', 'size', + 'matrix', + 'x', + 'y', + 'z', + 'r', + 'theta', + 'rho', + 'phi', + 'elevation', + 'latitude', + 'longitude', 'active', 'canceled', 'closed', @@ -344,6 +366,17 @@ protected function casts(): array 'only_guest' => 'boolean', 'allow_public' => 'boolean', 'status' => 'integer', + 'matrix' => 'array', + 'x' => 'integer', + 'y' => 'integer', + 'z' => 'integer', + 'r' => 'float', + 'theta' => 'float', + 'rho' => 'float', + 'phi' => 'float', + 'elevation' => 'float', + 'latitude' => 'float', + 'longitude' => 'float', 'rank' => 'integer', 'size' => 'integer', 'active' => 'boolean', @@ -426,6 +459,18 @@ public function flow(): HasOne ); } + /** + * The matrix of the backlog. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The milestone of the backlog. */ @@ -565,7 +610,7 @@ public function sprints(): HasMany { return $this->hasMany( Sprint::class, - 'sprint_id', + 'backlog_id', 'id' ); } @@ -577,7 +622,7 @@ public function tickets(): HasMany { return $this->hasMany( Ticket::class, - 'ticket_id', + 'backlog_id', 'id' ); } diff --git a/src/Models/Board.php b/src/Models/Board.php index ded648e..d984637 100644 --- a/src/Models/Board.php +++ b/src/Models/Board.php @@ -1,9 +1,9 @@ null, 'epic_id' => null, 'flow_id' => null, + 'matrix_id' => null, 'milestone_id' => null, 'note_id' => null, 'project_id' => null, @@ -55,8 +158,8 @@ class Board extends Model 'postponed_at' => null, 'published_at' => null, 'released_at' => null, - 'resolved_at' => null, 'resumed_at' => null, + 'resolved_at' => null, 'suspended_at' => null, 'gids' => 0, 'po' => 0, @@ -69,7 +172,7 @@ class Board extends Model 'status' => 0, 'rank' => 0, 'size' => 0, - 'matrix' => '', + 'matrix' => '{}', 'x' => null, 'y' => null, 'z' => null, @@ -84,6 +187,7 @@ class Board extends Model 'canceled' => false, 'closed' => false, 'completed' => false, + 'cron' => false, 'duplicate' => false, 'fixed' => false, 'flagged' => false, @@ -134,6 +238,7 @@ class Board extends Model 'backlog_id', 'epic_id', 'flow_id', + 'matrix_id', 'milestone_id', 'note_id', 'project_id', @@ -185,6 +290,7 @@ class Board extends Model 'canceled', 'closed', 'completed', + 'cron', 'duplicate', 'fixed', 'flagged', @@ -217,7 +323,6 @@ class Board extends Model 'board', 'flow', 'meta', - 'notes', 'options', 'roadmap', 'sources', @@ -260,7 +365,7 @@ protected function casts(): array 'status' => 'integer', 'rank' => 'integer', 'size' => 'integer', - 'matrix' => 'string', + 'matrix' => 'array', 'x' => 'integer', 'y' => 'integer', 'z' => 'integer', @@ -275,6 +380,7 @@ protected function casts(): array 'canceled' => 'boolean', 'closed' => 'boolean', 'completed' => 'boolean', + 'cron' => 'boolean', 'duplicate' => 'boolean', 'fixed' => 'boolean', 'flagged' => 'boolean', @@ -350,6 +456,18 @@ public function flow(): HasOne ); } + /** + * The matrix of the board. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The milestone of the board. */ diff --git a/src/Models/Sprint.php b/src/Models/Sprint.php index 3f833fa..0ccbd27 100644 --- a/src/Models/Sprint.php +++ b/src/Models/Sprint.php @@ -1,9 +1,9 @@ null, 'epic_id' => null, 'flow_id' => null, + 'matrix_id' => null, 'milestone_id' => null, 'note_id' => null, 'project_id' => null, @@ -55,8 +158,8 @@ class Sprint extends Model 'postponed_at' => null, 'published_at' => null, 'released_at' => null, - 'resolved_at' => null, 'resumed_at' => null, + 'resolved_at' => null, 'suspended_at' => null, 'gids' => 0, 'po' => 0, @@ -69,7 +172,7 @@ class Sprint extends Model 'status' => 0, 'rank' => 0, 'size' => 0, - 'matrix' => '', + 'matrix' => '{}', 'x' => null, 'y' => null, 'z' => null, @@ -84,6 +187,7 @@ class Sprint extends Model 'canceled' => false, 'closed' => false, 'completed' => false, + 'cron' => false, 'duplicate' => false, 'fixed' => false, 'flagged' => false, @@ -135,6 +239,7 @@ class Sprint extends Model 'board_id', 'epic_id', 'flow_id', + 'matrix_id', 'milestone_id', 'note_id', 'project_id', @@ -185,6 +290,7 @@ class Sprint extends Model 'canceled', 'closed', 'completed', + 'cron', 'duplicate', 'fixed', 'flagged', @@ -217,7 +323,6 @@ class Sprint extends Model 'board', 'flow', 'meta', - 'notes', 'options', 'roadmap', 'sources', @@ -260,7 +365,7 @@ protected function casts(): array 'status' => 'integer', 'rank' => 'integer', 'size' => 'integer', - 'matrix' => 'string', + 'matrix' => 'array', 'x' => 'integer', 'y' => 'integer', 'z' => 'integer', @@ -275,6 +380,7 @@ protected function casts(): array 'canceled' => 'boolean', 'closed' => 'boolean', 'completed' => 'boolean', + 'cron' => 'boolean', 'duplicate' => 'boolean', 'fixed' => 'boolean', 'flagged' => 'boolean', @@ -362,6 +468,18 @@ public function flow(): HasOne ); } + /** + * The matrix of the board. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The milestone of the sprint. */ diff --git a/src/Models/Ticket.php b/src/Models/Ticket.php index 159c0fc..a768356 100644 --- a/src/Models/Ticket.php +++ b/src/Models/Ticket.php @@ -202,7 +202,7 @@ class Ticket extends Model 'status' => 0, 'rank' => 0, 'size' => 0, - 'matrix' => '', + 'matrix' => '{}', 'x' => null, 'y' => null, 'z' => null, @@ -591,6 +591,18 @@ public function flow(): HasOne ); } + /** + * The matrix of the ticket. + */ + public function matrix(): HasOne + { + return $this->hasOne( + Matrix::class, + 'id', + 'matrix_id' + ); + } + /** * The milestone of the ticket. */ diff --git a/tests/Feature/Models/Backlog/ModelTest.php b/tests/Feature/Models/Backlog/ModelTest.php index 3b66bc2..5211a2a 100644 --- a/tests/Feature/Models/Backlog/ModelTest.php +++ b/tests/Feature/Models/Backlog/ModelTest.php @@ -17,6 +17,14 @@ class ModelTest extends ModelCase protected bool $hasRelationships = true; + /** + * @var array> Test hasMany relationships. + */ + protected array $hasMany = [ + 'sprints' => ['key' => 'backlog_id', 'modelClass' => \Playground\Matrix\Models\Sprint::class], + 'tickets' => ['key' => 'backlog_id', 'modelClass' => \Playground\Matrix\Models\Ticket::class], + ]; + protected array $hasOne = [ 'creator' => [ 'key' => 'created_by_id', @@ -53,6 +61,11 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'milestone' => [ 'key' => 'milestone_id', 'rule' => 'create', diff --git a/tests/Feature/Models/Board/ModelTest.php b/tests/Feature/Models/Board/ModelTest.php index 0ee8bf9..fc03fe0 100644 --- a/tests/Feature/Models/Board/ModelTest.php +++ b/tests/Feature/Models/Board/ModelTest.php @@ -53,6 +53,11 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'milestone' => [ 'key' => 'milestone_id', 'rule' => 'create', diff --git a/tests/Feature/Models/Sprint/ModelTest.php b/tests/Feature/Models/Sprint/ModelTest.php index 93eec4e..2f88b6e 100644 --- a/tests/Feature/Models/Sprint/ModelTest.php +++ b/tests/Feature/Models/Sprint/ModelTest.php @@ -58,6 +58,11 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'milestone' => [ 'key' => 'milestone_id', 'rule' => 'create', diff --git a/tests/Feature/Models/Ticket/ModelTest.php b/tests/Feature/Models/Ticket/ModelTest.php index 60abfa8..d5c5efd 100644 --- a/tests/Feature/Models/Ticket/ModelTest.php +++ b/tests/Feature/Models/Ticket/ModelTest.php @@ -58,11 +58,21 @@ class ModelTest extends ModelCase 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Epic::class, ], + 'fixedBy' => [ + 'key' => 'fixed_by_id', + 'rule' => 'create', + 'modelClass' => \Playground\Models\User::class, + ], 'flow' => [ 'key' => 'flow_id', 'rule' => 'create', 'modelClass' => \Playground\Matrix\Models\Flow::class, ], + 'matrix' => [ + 'key' => 'matrix_id', + 'rule' => 'create', + 'modelClass' => \Playground\Matrix\Models\Matrix::class, + ], 'milestone' => [ 'key' => 'milestone_id', 'rule' => 'create',