Merge branch 'master' into tryUpgradeView
This commit is contained in:
@@ -10,6 +10,10 @@ framework:
|
||||
# Redis
|
||||
app: 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)
|
||||
#app: cache.adapter.apcu
|
||||
|
||||
@@ -15,6 +15,24 @@ doctrine:
|
||||
validate_xml_mapping: true
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
||||
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:
|
||||
App:
|
||||
type: attribute
|
||||
|
||||
@@ -24,6 +24,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
class BaseController extends AbstractController
|
||||
{
|
||||
@@ -37,15 +38,16 @@ class BaseController extends AbstractController
|
||||
}
|
||||
#[Route('/reports/{monthId}', name: 'app_base')]
|
||||
#[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);
|
||||
$isOverdue = false;
|
||||
if ($monthId > -1) {
|
||||
$monthCurrentDate = $monthHelper->getCurrentMonthDate($monthId);
|
||||
$reportsAll = $this->takeReportsAll($entityManager,$cache,$monthCurrentDate);
|
||||
|
||||
if ($monthId > -1) {
|
||||
$reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrentDate);
|
||||
} else {
|
||||
$reportsAll = $entityManager->getRepository(Reports::class)->findAllOverdue();
|
||||
$isOverdue = true;
|
||||
}
|
||||
|
||||
@@ -70,4 +72,15 @@ class BaseController extends AbstractController
|
||||
'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();
|
||||
$entityManager->persist($newClient);
|
||||
$entityManager->flush();
|
||||
$entityManager->getCache()->evictEntityRegion(Clients::class);
|
||||
if (!$isEdit) {
|
||||
$addReports->setClient($newClient);
|
||||
$addReports->init();
|
||||
|
||||
@@ -58,6 +58,7 @@ class ReportsController extends AbstractController
|
||||
}
|
||||
$entityManager->persist($report);
|
||||
$entityManager->flush();
|
||||
$entityManager->getCache()->evictCollection(Reports::class,"reportsTodos",$report->getId());
|
||||
$reportsService->tryAddNextReport();
|
||||
}
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
|
||||
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ClientsRepository::class)]
|
||||
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'client_cache')]
|
||||
class Clients
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
||||
@@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: NotesRepository::class)]
|
||||
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'default_cache')]
|
||||
class Notes
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
||||
@@ -11,6 +11,8 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ReportsRepository::class)]
|
||||
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'report_cache')]
|
||||
|
||||
class Reports
|
||||
{
|
||||
#[ORM\Id]
|
||||
@@ -29,6 +31,7 @@ class Reports
|
||||
* @var Collection<int, ReportsTodo>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: ReportsTodo::class, mappedBy: 'report', orphanRemoval: true)]
|
||||
#[ORM\Cache(usage: 'READ_ONLY', region: 'report_cache')]
|
||||
|
||||
private Collection $reportsTodos;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ReportsTodoRepository::class)]
|
||||
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'report_cache')]
|
||||
class ReportsTodo
|
||||
{
|
||||
#[ORM\Id]
|
||||
@@ -19,7 +20,7 @@ class ReportsTodo
|
||||
#[ORM\Column(type: Types::SMALLINT, enumType: ReportTodoEnum::class)]
|
||||
private ?ReportTodoEnum $name = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\ManyToOne(inversedBy: 'reportsTodos')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
|
||||
private ?Reports $report = null;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ScheduleRepository::class)]
|
||||
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'schedule_cache')]
|
||||
class Schedule
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
||||
@@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
||||
#[ORM\Cache(usage: 'READ_ONLY', region: 'user_cache')]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[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();
|
||||
if ($monthId==0) {
|
||||
$currentMonth = intval(date("n"));
|
||||
|
||||
@@ -84,6 +84,7 @@ class AddReports
|
||||
$report->setNumber($numberOfReports + 1);
|
||||
$this->manager->persist($report);
|
||||
$this->manager->flush();
|
||||
$this->manager->getCache()->evictEntityRegion(Reports::class);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -107,6 +108,7 @@ class AddReports
|
||||
$report->setDateStart($dateToReport->modify("+".self::NEXT_REPORT_MONTH." months"));
|
||||
$this->manager->persist($report);
|
||||
$this->manager->flush();
|
||||
$this->manager->getCache()->evictEntityRegion(Reports::class);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user