Merge branch 'develop' into trunk

This commit is contained in:
Vincent BRIDIER 2023-06-29 10:12:14 +02:00
commit bbe4478c09
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
6 changed files with 134 additions and 140 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

@ -28,6 +28,42 @@ class ScheduleController extends Controller
parent::__construct();
$this->middleware('is-admin');
}
/**
* Create the date
* @param \Illuminate\Http\Request $request
* @return \Carbon\CarbonImmutable|false
*/
private function dateCreation(Request $request)
{
$date = CarbonImmutable::now()->startOfWeek();
if ($request->p) {
$date = CarbonImmutable::createFromFormat('d/m/Y', $request->p)->startOfWeek();
}
return $date;
}
/**
* Create the users table.
* @param \Illuminate\Http\Request $request
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
*/
private function createUsers(Request $request)
{
$users = [];
if (!is_null($request->cookie('userAuthSchedule'))) {
$dbusers = User::where('id', auth()->user()->id)->get();
} else {
$dbusers = User::where('role', Role::developper())->get();
}
foreach ($dbusers as $user) {
$users[$user->id] = ['name' => $user->name];
}
return $users;
}
/**
* Display schedule.
* @param \Illuminate\Http\Request $request
@ -41,22 +77,10 @@ class ScheduleController extends Controller
return $this->showAllSchedules();
}
$date = CarbonImmutable::now()->startOfWeek();
$date = $this->dateCreation($request);
$nbweeks = config('schedules.shownWeeks');
if ($request->p) {
$date = CarbonImmutable::createFromFormat('d/m/Y', $request->p)->startOfWeek();
}
$users = $this->createUsers($request);
$users = [];
if (!is_null($request->cookie('userAuthSchedule'))) {
$dbusers = User::where('id', auth()->user()->id)->get();
} else {
$dbusers = User::where('role', Role::developper())->get();
}
foreach ($dbusers as $user) {
$users[$user->id] = ['name' => $user->name];
}
$schedules = Schedule::whereHas('user', function (Builder $query) use ($request) {
$query->where('deleted_at', null);
$query->where('role', Role::developper());
@ -97,7 +121,6 @@ class ScheduleController extends Controller
'type' => $schedule->activity,
'text' => $schedule->description,
'id_lie' => $id_lie,
// $schedule->id_lie,
'model_lie' => $model_lie,
),
)
@ -112,7 +135,6 @@ class ScheduleController extends Controller
'type' => $schedule->activity,
'text' => $schedule->description,
'id_lie' => $id_lie,
// $schedule->id_lie,
'model_lie' => $model_lie,
),
);
@ -125,14 +147,9 @@ class ScheduleController extends Controller
'type' => $schedule->activity,
'text' => $schedule->description,
'id_lie' => $id_lie,
// $schedule->id_lie,
'model_lie' => $model_lie,
);
}
// else {
// same date
// should never be here
// }.
}//end if
}//end if
$prevUserId = $schedule->user_id;

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));