Merge branch 'master' into tryUpgradeView
This commit is contained in:
@@ -10,6 +10,10 @@ framework:
|
|||||||
# Redis
|
# Redis
|
||||||
app: cache.adapter.redis
|
app: cache.adapter.redis
|
||||||
system: cache.adapter.redis
|
system: cache.adapter.redis
|
||||||
|
default_redis_provider: '%env(REDIS_URL)%'
|
||||||
|
pools:
|
||||||
|
database.cache:
|
||||||
|
adapter: cache.adapter.redis
|
||||||
|
|
||||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||||
#app: cache.adapter.apcu
|
#app: cache.adapter.apcu
|
||||||
|
|||||||
@@ -15,6 +15,24 @@ doctrine:
|
|||||||
validate_xml_mapping: true
|
validate_xml_mapping: true
|
||||||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
||||||
auto_mapping: true
|
auto_mapping: true
|
||||||
|
second_level_cache:
|
||||||
|
enabled: true
|
||||||
|
regions:
|
||||||
|
user_cache:
|
||||||
|
lifetime: 8640000
|
||||||
|
cache_driver: { type: service, id: database.cache }
|
||||||
|
schedule_cache:
|
||||||
|
lifetime: 864000
|
||||||
|
cache_driver: { type: service, id: database.cache }
|
||||||
|
report_cache:
|
||||||
|
lifetime: 864000
|
||||||
|
cache_driver: { type: service, id: database.cache }
|
||||||
|
client_cache:
|
||||||
|
lifetime: 864000
|
||||||
|
cache_driver: { type: service, id: database.cache }
|
||||||
|
default_cache:
|
||||||
|
lifetime: 864000
|
||||||
|
cache_driver: { type: service, id: database.cache }
|
||||||
mappings:
|
mappings:
|
||||||
App:
|
App:
|
||||||
type: attribute
|
type: attribute
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
|
||||||
class BaseController extends AbstractController
|
class BaseController extends AbstractController
|
||||||
{
|
{
|
||||||
@@ -37,15 +38,16 @@ class BaseController extends AbstractController
|
|||||||
}
|
}
|
||||||
#[Route('/reports/{monthId}', name: 'app_base')]
|
#[Route('/reports/{monthId}', name: 'app_base')]
|
||||||
#[IsGranted('reportView')]
|
#[IsGranted('reportView')]
|
||||||
public function reportsIndex(EntityManagerInterface $entityManager, OverdueReports $overdueReports, int $monthId = 0) : Response
|
public function reportsIndex(EntityManagerInterface $entityManager, CacheInterface $cache, OverdueReports $overdueReports, int $monthId = 0) : Response
|
||||||
{
|
{
|
||||||
$monthHelper = new MonthHelper($overdueReports);
|
$monthHelper = new MonthHelper($overdueReports);
|
||||||
$isOverdue = false;
|
$isOverdue = false;
|
||||||
if ($monthId > -1) {
|
|
||||||
$monthCurrentDate = $monthHelper->getCurrentMonthDate($monthId);
|
$monthCurrentDate = $monthHelper->getCurrentMonthDate($monthId);
|
||||||
|
$reportsAll = $this->takeReportsAll($entityManager,$cache,$monthCurrentDate);
|
||||||
|
|
||||||
|
if ($monthId > -1) {
|
||||||
$reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrentDate);
|
$reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrentDate);
|
||||||
} else {
|
} else {
|
||||||
$reportsAll = $entityManager->getRepository(Reports::class)->findAllOverdue();
|
|
||||||
$isOverdue = true;
|
$isOverdue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,4 +72,15 @@ class BaseController extends AbstractController
|
|||||||
'countOverdueLeft' => $overdueReports->getLeftCount()
|
'countOverdueLeft' => $overdueReports->getLeftCount()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function takeReportsAll(EntityManagerInterface $entityManager, CacheInterface $cache, ?\DateTime $monthCurrent = null) : array
|
||||||
|
{
|
||||||
|
if ($monthCurrent !== null) {
|
||||||
|
$ret = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrent);
|
||||||
|
} else {
|
||||||
|
$ret = $entityManager->getRepository(Reports::class)->findAllOverdue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ class ClientController extends AbstractController
|
|||||||
$newClient = $form->getData();
|
$newClient = $form->getData();
|
||||||
$entityManager->persist($newClient);
|
$entityManager->persist($newClient);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
$entityManager->getCache()->evictEntityRegion(Clients::class);
|
||||||
if (!$isEdit) {
|
if (!$isEdit) {
|
||||||
$addReports->setClient($newClient);
|
$addReports->setClient($newClient);
|
||||||
$addReports->init();
|
$addReports->init();
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class ReportsController extends AbstractController
|
|||||||
}
|
}
|
||||||
$entityManager->persist($report);
|
$entityManager->persist($report);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
$entityManager->getCache()->evictCollection(Reports::class,"reportsTodos",$report->getId());
|
||||||
$reportsService->tryAddNextReport();
|
$reportsService->tryAddNextReport();
|
||||||
}
|
}
|
||||||
return $this->redirect($request->headers->get('referer'));
|
return $this->redirect($request->headers->get('referer'));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ClientsRepository::class)]
|
#[ORM\Entity(repositoryClass: ClientsRepository::class)]
|
||||||
|
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'client_cache')]
|
||||||
class Clients
|
class Clients
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\Types;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: NotesRepository::class)]
|
#[ORM\Entity(repositoryClass: NotesRepository::class)]
|
||||||
|
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'default_cache')]
|
||||||
class Notes
|
class Notes
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ use Doctrine\DBAL\Types\Types;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ReportsRepository::class)]
|
#[ORM\Entity(repositoryClass: ReportsRepository::class)]
|
||||||
|
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'report_cache')]
|
||||||
|
|
||||||
class Reports
|
class Reports
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
@@ -29,6 +31,7 @@ class Reports
|
|||||||
* @var Collection<int, ReportsTodo>
|
* @var Collection<int, ReportsTodo>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: ReportsTodo::class, mappedBy: 'report', orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: ReportsTodo::class, mappedBy: 'report', orphanRemoval: true)]
|
||||||
|
#[ORM\Cache(usage: 'READ_ONLY', region: 'report_cache')]
|
||||||
|
|
||||||
private Collection $reportsTodos;
|
private Collection $reportsTodos;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ReportsTodoRepository::class)]
|
#[ORM\Entity(repositoryClass: ReportsTodoRepository::class)]
|
||||||
|
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'report_cache')]
|
||||||
class ReportsTodo
|
class ReportsTodo
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
@@ -19,7 +20,7 @@ class ReportsTodo
|
|||||||
#[ORM\Column(type: Types::SMALLINT, enumType: ReportTodoEnum::class)]
|
#[ORM\Column(type: Types::SMALLINT, enumType: ReportTodoEnum::class)]
|
||||||
private ?ReportTodoEnum $name = null;
|
private ?ReportTodoEnum $name = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
#[ORM\ManyToOne(inversedBy: 'reportsTodos')]
|
||||||
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
|
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
|
||||||
private ?Reports $report = null;
|
private ?Reports $report = null;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Types;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ScheduleRepository::class)]
|
#[ORM\Entity(repositoryClass: ScheduleRepository::class)]
|
||||||
|
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'schedule_cache')]
|
||||||
class Schedule
|
class Schedule
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
|||||||
|
|
||||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
||||||
|
#[ORM\Cache(usage: 'READ_ONLY', region: 'user_cache')]
|
||||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
|
|||||||
@@ -32,8 +32,11 @@ class MonthHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCurrentMonthDate(int $monthId) : \DateTime
|
public function getCurrentMonthDate(int $monthId) : ?\DateTime
|
||||||
{
|
{
|
||||||
|
if ($monthId < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$months = $this->takeMonths();
|
$months = $this->takeMonths();
|
||||||
if ($monthId==0) {
|
if ($monthId==0) {
|
||||||
$currentMonth = intval(date("n"));
|
$currentMonth = intval(date("n"));
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class AddReports
|
|||||||
$report->setNumber($numberOfReports + 1);
|
$report->setNumber($numberOfReports + 1);
|
||||||
$this->manager->persist($report);
|
$this->manager->persist($report);
|
||||||
$this->manager->flush();
|
$this->manager->flush();
|
||||||
|
$this->manager->getCache()->evictEntityRegion(Reports::class);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -107,6 +108,7 @@ class AddReports
|
|||||||
$report->setDateStart($dateToReport->modify("+".self::NEXT_REPORT_MONTH." months"));
|
$report->setDateStart($dateToReport->modify("+".self::NEXT_REPORT_MONTH." months"));
|
||||||
$this->manager->persist($report);
|
$this->manager->persist($report);
|
||||||
$this->manager->flush();
|
$this->manager->flush();
|
||||||
|
$this->manager->getCache()->evictEntityRegion(Reports::class);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user