Skip to content

Commit

Permalink
Merge branch 'main' into PPF-651
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVHG authored Dec 2, 2024
2 parents b6b1b3e + 96e6044 commit fde65ef
Show file tree
Hide file tree
Showing 7 changed files with 445 additions and 462 deletions.
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
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 fde65ef

Please sign in to comment.