Merge branch '15-parse-error-jobs-autocloseoldtickets-php' into 'develop'

Resolve "Parse Error Jobs/AutoCloseOldTickets.php"

Closes #15

See merge request ldc-web/projets/support-web!27
This commit is contained in:
Vincent BRIDIER 2023-06-29 08:11:01 +00:00
commit 6229cf7518
5 changed files with 96 additions and 119 deletions

View file

@ -1,118 +1,19 @@
include:
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'lint/lint7.3.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'security/security7.3.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'build/build7.3.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'test/test.yml'
stages:
- Security
- CodingStandards
- Builds
composer-security:
stage: Security
image: $CI_REGISTRY/service-web-lab/ldc-web-images-docker/ldcweb-qa:php7.3-1.0
script:
- local-php-security-checker --format=json --path=./composer.lock > composer-security-checker-report.json
artifacts:
when: on_failure
expose_as: 'composer-security-checker'
paths:
- composer-security-checker-report.json
allow_failure: true
needs: []
npm-security:
stage: Security
image: node:17.9.1
before_script:
- npm install --location=global audit-ci@^6
script:
- audit-ci -p npm -o json > npm-security-checker-report.json
artifacts:
when: on_failure
expose_as: 'npm-security-checker'
paths:
- npm-security-checker-report.json
allow_failure: true
needs: []
phpcs:
stage: CodingStandards
image: $CI_REGISTRY/service-web-lab/ldc-web-images-docker/ldcweb-qa:php7.3-1.0
before_script:
- composer config gitlab-token.gitlab.com $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD
- composer install
cache:
paths:
- vendor/
script:
- vendor/bin/phpcs --report=junit --report-file=phpcs-report.xml
artifacts:
when: on_failure
expose_as: 'phpcs'
paths:
- phpcs-report.xml
reports:
junit: phpcs-report.xml
allow_failure: false
needs:
- composer-security
- npm-security
eslint:
stage: CodingStandards
image: node:17.9.1
before_script:
- npm install
cache:
paths:
- node_modules/
script:
- npm run eslint-ci --silent > eslint-report.xml
artifacts:
when: on_failure
expose_as: 'eslint'
paths:
- eslint-report.xml
reports:
junit: eslint-report.xml
allow_failure: false
needs:
- composer-security
- npm-security
stylelint:
stage: CodingStandards
image: node:17.9.1
before_script:
- npm install
cache:
paths:
- node_modules/
script:
- npm run stylelint-ci --silent > stylelint-report.json
artifacts:
when: on_failure
expose_as: 'stylelint'
paths:
- stylelint-report.json
allow_failure: false
needs:
- composer-security
- npm-security
front-build:
stage: Builds
image: node:17.9.1
before_script:
- npm install
cache:
paths:
- node_modules/
script:
- npm run prod > front-build-report.json
artifacts:
when: on_failure
expose_as: 'front-build-report'
paths:
- front-build-report.json
allow_failure: false
needs:
- phpcs
- eslint
- stylelint
- lint
- security
- build
- test

View file

@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Jobs\AutoCloseOldTickets as JobsAutoCloseOldTickets;
use Illuminate\Console\Command;
class AutoCloseOldTickets extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tickets:auto-close-old';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the AutoCloseOldTickets job.';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$this->info('Running the Job, this could take some time.');
$job = new JobsAutoCloseOldTickets();
$job->handle();
$this->info('Job completed');
return 0;
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Jobs\WarnBeforeAutoCloseTicket as JobsWarnBeforeAutoCloseTicket;
use Illuminate\Console\Command;
class WarnBeforeAutoCloseTicket extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tickets:warn-before-auto-close';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the WarnBeforeAutoCloseTicket job.';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$this->info('Running the Job, this could take some time.');
$job = new JobsWarnBeforeAutoCloseTicket();
$job->handle();
$this->info('Job completed');
return 0;
}
}

View file

@ -21,7 +21,7 @@ class AutoCloseOldTickets
$message = 'En l\'absence d\'activitée depuis 15 jours ce ticket est automatiquement clos et archivé.';
$tickets = Ticket::where(function ($q) {
$q->where('status', TicketStatus::production())
->orWhere('status', TicketStatus::waitingValidation())
->orWhere('status', TicketStatus::waitingValidation());
})->whereDate('updated_at', '<=', Carbon::now()->subDays($limitDays))
->whereDoesntHave('messages', function ($q) use ($limitDays) {
$q->whereDate('updated_at', '>', Carbon::now()->subDays($limitDays));

View file

@ -24,7 +24,7 @@ class WarnBeforeAutoCloseTicket
$messageToUser = 'En l\'absence d\'activitée, ou de réponse de votre part ce ticket sera automatiquement clos et archivé dans %s jours.';
$tickets = Ticket::where(function ($q) {
$q->where('status', TicketStatus::production())
->orWhere('status', TicketStatus::waitingValidation())
->orWhere('status', TicketStatus::waitingValidation());
})->whereDate('updated_at', '<=', Carbon::now()->subDays($warningDays))
->whereDoesntHave('messages', function ($q) use ($warningDays) {
$q->whereDate('updated_at', '>', Carbon::now()->subDays($warningDays));