-
Notifications
You must be signed in to change notification settings - Fork 37
feat(integration-github): add repository purpose filtering #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79d4c0c
896834e
80967c2
0c619ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\DB; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::table('github_repositories', static function (Blueprint $table): void { | ||
| $table->string('purpose')->nullable(); | ||
| }); | ||
|
|
||
| DB::table('github_repositories')->update(['purpose' => 'contributions']); | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace He4rt\IntegrationGithub\Enums; | ||
|
|
||
| enum PurposeType: string | ||
| { | ||
| case Contributions = 'contributions'; | ||
| case Challenge = 'challenge'; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| use Carbon\CarbonInterface; | ||
| use He4rt\Identity\Tenant\Models\Tenant; | ||
| use He4rt\IntegrationGithub\Database\Factories\GithubRepositoryFactory; | ||
| use He4rt\IntegrationGithub\Enums\PurposeType; | ||
| use Illuminate\Database\Eloquent\Attributes\Table; | ||
| use Illuminate\Database\Eloquent\Builder; | ||
| use Illuminate\Database\Eloquent\Casts\Attribute; | ||
|
|
@@ -21,6 +22,7 @@ | |
| * @property string $tenant_id | ||
| * @property string $full_name | ||
| * @property bool $enabled | ||
| * @property PurposeType $purpose | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PHPDoc already declares protected function casts(): array
{
return [
'enabled' => 'boolean',
'last_backfilled_at' => 'datetime',
'purpose' => PurposeType::class,
];
}This makes the attribute strongly typed and keeps the PHPDoc honest about the real behavior. |
||
| * @property CarbonInterface|null $last_backfilled_at | ||
| * @property CarbonInterface|null $created_at | ||
| * @property CarbonInterface|null $updated_at | ||
|
|
@@ -75,6 +77,7 @@ protected function casts(): array | |
| return [ | ||
| 'enabled' => 'boolean', | ||
| 'last_backfilled_at' => 'datetime', | ||
| 'purpose' => PurposeType::class, | ||
| ]; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the idea of implementing an enum for this value, I would use a nullable string rather than a default value. Then, I would add an extra step to fill it with the default values.
Note
Do not use enums in migrations.
This could be impacted by a change in the future.
It will not be implemented if migration has already occurred; it will only be implemented on new databases.
Before applying/implementing this suggestion, I would like to hear from @danielhe4rt and @Clintonrocha98. Default values aren't a problem, but they could be in the future.