Skip to content

Commit

Permalink
Merge branch 'main' into PPF-647-dump-db-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVHG authored Dec 10, 2024
2 parents 33b0910 + 25b4740 commit 8e6ab60
Show file tree
Hide file tree
Showing 10 changed files with 1,122 additions and 975 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ npm-lint-check:
npm-types-check:
vendor/bin/sail npm run types:check

npm-ci: npm-format npm-lint-check npm-types-check

e2e-install:
docker-compose exec laravel npx playwright install chromium --with-deps

Expand Down
9 changes: 9 additions & 0 deletions app/Domain/Integrations/Models/IntegrationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use App\Keycloak\Models\KeycloakClientModel;
use App\Mails\Template\TemplateName;
use App\Models\UuidModel;
use App\Nova\Filters\AdminInformationFilter;
use App\UiTiDv1\Models\UiTiDv1ConsumerModel;
use App\UiTiDv1\UiTiDv1Environment;
use Illuminate\Database\Eloquent\Builder;
Expand All @@ -49,6 +50,7 @@
* @property KeyVisibility $key_visibility
* @property string $website
* @method static Builder|IntegrationModel withoutMailSent(TemplateName $templateName)
* @method static Builder|IntegrationModel notOnHold()
* @mixin Builder
* */
final class IntegrationModel extends UuidModel
Expand Down Expand Up @@ -409,4 +411,11 @@ public function scopeWithoutMailSent(Builder $query, TemplateName $templateName)
$query->where('template_name', $templateName->value);
});
}

public function scopeNotOnHold(Builder $query): Builder
{
return $query->whereDoesntHave('adminInformation', function ($q) {
$q->where(AdminInformationFilter::ON_HOLD_COLUMN, '=', 1);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getDraftsByTypeAndBetweenMonthsOld(IntegrationType $type, int $s
->whereBetween('created_at', [Carbon::now()->subMonths($endMonths), Carbon::now()->subMonths($startMonths)])
->has('contacts') // This ensures that only integrations with at least one contact are returned
->withoutMailSent($templateName)
->notOnHold()
->get()
->map(static function (IntegrationModel $integrationModel) {
return $integrationModel->toDomain();
Expand Down
3 changes: 2 additions & 1 deletion app/Domain/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
use App\Mails\Template\TemplateName;
use App\Mails\Template\Templates;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Mime\Address;

final class MailManager
final class MailManager implements ShouldQueue
{
use Queueable;

Expand Down
6 changes: 4 additions & 2 deletions app/Nova/Filters/AdminInformationFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ final class AdminInformationFilter extends Filter
{
public $name = 'On hold';

public const ON_HOLD_COLUMN = 'on_hold';

private const ON_HOLD = 'on_hold';
private const NOT_ON_HOLD = 'not_on_hold';

public function apply(NovaRequest $request, $query, $value): Builder
{
if ($value === self::ON_HOLD) {
return $query->whereHas('adminInformation', function ($q) {
$q->where(self::ON_HOLD, '=', 1);
$q->where(self::ON_HOLD_COLUMN, '=', 1);
});
}

if ($value === self::NOT_ON_HOLD) {
return $query->whereDoesntHave('adminInformation', function ($q) {
$q->where(self::ON_HOLD, '=', 1);
$q->where(self::ON_HOLD_COLUMN, '=', 1);
});
}

Expand Down
Loading

0 comments on commit 8e6ab60

Please sign in to comment.