From 960b8c555032b4ac01e07e02a988a1538e48e3c8 Mon Sep 17 00:00:00 2001 From: NDZHER <156980843+LexaFrontDev@users.noreply.github.com> Date: Tue, 16 Sep 2025 15:28:59 +0500 Subject: [PATCH] fix: repository and ResourceSyncService.php update: README.md README.ru.md --- .env | 14 +++--- Makefile | 7 +++ README.md | 26 +++++------ README.ru.md | 4 +- docker-compose.yml | 2 +- .../UseCase/AuthUseCase/UsersAuth.php | 1 - .../QueryLanguageUseCases.php | 2 +- .../CommandResourceUseCase.php | 4 +- .../ResourceService/ResourceSyncInterface.php | 2 +- .../DataJunction/DataJunctionRepository.php | 12 ++--- .../DatesDaily/DatesDailyRepository.php | 2 +- .../DatesRepeat/DatesRepeatRepository.php | 2 +- .../DatesWeekly/DatesWeeklyRepository.php | 2 +- .../Habits/HabitsHistoryRepository.php | 8 ++-- .../Repository/Habits/HabitsRepository.php | 6 +-- .../Language/LanguagePageRepositoru.php | 4 +- .../Matric/MatricColumnRepository.php | 2 +- .../Matric/MatricJunctionRepository.php | 4 +- .../Pomdor/PomodorHistoryRepository.php | 6 +-- .../Repository/Purpose/PurposeRepository.php | 6 +-- .../Repository/Storage/StorageRepository.php | 2 +- .../Repository/Tasks/TasksRepository.php | 4 +- .../Repository/UsersRepository.php | 4 +- .../ResourceService/ResourceSyncService.php | 46 ++++++++----------- 24 files changed, 87 insertions(+), 85 deletions(-) diff --git a/.env b/.env index 51efcad..eefa3cf 100644 --- a/.env +++ b/.env @@ -19,12 +19,12 @@ MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!" ###> lexik/jwt-authentication-bundle ### JWT_PRIVATE_KEY_PATH=%kernel.project_dir%/config/jwt/private.pem JWT_PUBLIC_KEY_PATH=%kernel.project_dir%/config/jwt/public.pem -JWT_PASSPHRASE= +JWT_PASSPHRASE=e357a5e49f1839042101695a96c07c9edfdf4939d4e91b1368d5c177153a71bc ###< lexik/jwt-authentication-bundle ### -VITE_CACHE_DB_NAME= -VITE_CACHE_STORE_NAME= -VITE_GOOGLE_CLIENT_ID= -VITE_GOOGLE_REDIRECT_URI= -VITE_PUSH_PUBLIC_KEY= -VITE_PUSH_PRIVATE_KEY= \ No newline at end of file +VITE_CACHE_DB_NAME=HabitAiCacheDev +VITE_CACHE_STORE_NAME=cache +VITE_GOOGLE_CLIENT_ID=643971601411-8n1r7vok0pk4v4q250dfpr4ibs17jfms.apps.googleusercontent.com +VITE_GOOGLE_REDIRECT_URI=http://localhost:8000/api/auth/google/callback +VITE_PUSH_PUBLIC_KEY=BGFRrWJKC5fnlb_eLwOIqa4bWlbBqRUIFvlDYQ1GX56Hl5Kv4KNopAIqZ2Tq6ohG4hIdLJoim4313yKUyNevXgo +VITE_PUSH_PRIVATE_KEY=EE9lQvPuHsWctURErU3bC4VG9wLguK-JcLI5iTo7G94 \ No newline at end of file diff --git a/Makefile b/Makefile index a86a7a7..75945c7 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,13 @@ up-prod-build: ## Start the docker hub in detached mode (no logs) start: build up ## Build and start the containers +db-reset: ## reset databases + @echo "Stopping containers..." + @$(DOCKER_COMP) down + @echo "Removing PostgreSQL volume..." + @docker volume rm timer_pgdata || true + @echo "Done. You can now rebuild containers." + stop: ## Stop the docker hub @$(DOCKER_COMP) stop diff --git a/README.md b/README.md index 95a37ef..37c7c9e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 🚀 HabitAi +**# 🚀 HabitAi **HabitAi** is an application designed to boost productivity with the help of Artificial Intelligence (AI). @@ -11,20 +11,20 @@ Project is currently under **active development**. ## 🛠️ Tech Stack * **Frontend:** Flutter, React, Vue -* **Backend:** Symfony (PHP 8.3) -* **Architecture:** Clean Architecture, Domain-Driven Design (DDD), Atomic Design + * **Backend:** Symfony (PHP 8.3) + * **Architecture:** Clean Architecture, Domain-Driven Design (DDD), Atomic Design ## ✨ Features * 📌 **Task Management** -* 🧭 **Eisenhower Matrix** for prioritization -* ⏳ **Pomodoro Timer** for focused work -* 🌍 **Multilingual Support** (5 languages) -* ⚡ **Frontend improvements**: + * 🧭 **Eisenhower Matrix** for prioritization + * ⏳ **Pomodoro Timer** for focused work + * 🌍 **Multilingual Support** (5 languages) + * ⚡ **Frontend improvements**: - * **Cache-Then-Network (CTN)** system for optimized data fetching - * **IndexedDB (IDB)** integration for offline access and reduced server load - * Centralized caching and efficient state management + * **Cache-Then-Network (CTN)** system for optimized data fetching + * **IndexedDB (IDB)** integration for offline access and reduced server load + * Centralized caching and efficient state management --- @@ -64,10 +64,10 @@ php bin/console app:resources:sync exit ``` -### 6. Start frontend +### 6. frontend host ```bash -npm run +http://localhost:10001/ ``` ### 7. Stop and remove containers @@ -81,5 +81,5 @@ make down ## 📌 Project Status 🔧 Under active development. -Stay tuned for updates and new releases! +Stay tuned for updates and new releases!** diff --git a/README.ru.md b/README.ru.md index 2d21972..1428485 100644 --- a/README.ru.md +++ b/README.ru.md @@ -62,10 +62,10 @@ php bin/console app:resources:sync exit ``` -### 6. Запуск фронтенда +### 6. Адрес фронтенда ```bash -npm run +http://localhost:10001/ ``` ### 7. Остановка и удаление контейнеров diff --git a/docker-compose.yml b/docker-compose.yml index b54b484..4139b4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf ports: - - 11001:80 + - 10001:80 restart: unless-stopped php: container_name: timer_app_php diff --git a/src/Aplication/UseCase/AuthUseCase/UsersAuth.php b/src/Aplication/UseCase/AuthUseCase/UsersAuth.php index be9cdc9..8d918ca 100644 --- a/src/Aplication/UseCase/AuthUseCase/UsersAuth.php +++ b/src/Aplication/UseCase/AuthUseCase/UsersAuth.php @@ -53,7 +53,6 @@ public function register(UsersForRegister $users): JwtTokenDto $userEntity = new Users(); $userEntity->setEmail($users->getEmail()); $userEntity->setName($users->getName()); - $hashedPassword = $this->passwordHasher->hash($users->getPassword()); $userEntity->setPassword($hashedPassword); $userEntity->setRole($users->getRole() ?: 'user'); diff --git a/src/Aplication/UseCase/LanguageUseCases/QueryLanguageUseCases.php b/src/Aplication/UseCase/LanguageUseCases/QueryLanguageUseCases.php index 9458f72..19bba09 100644 --- a/src/Aplication/UseCase/LanguageUseCases/QueryLanguageUseCases.php +++ b/src/Aplication/UseCase/LanguageUseCases/QueryLanguageUseCases.php @@ -20,7 +20,7 @@ public function getTranslatePageByLang(string $version, string $prefixLang): Lan { $translate = $this->language->getPageTranslateByLangId($version, $prefixLang); if (empty($translate)) { - throw new MessageException('Перевод не получено'); + throw new MessageException("Перевод не получено $translate"); } return $translate; diff --git a/src/Aplication/UseCase/ResourceUseCase/CommandResourceUseCase.php b/src/Aplication/UseCase/ResourceUseCase/CommandResourceUseCase.php index 5031a78..f3a695c 100644 --- a/src/Aplication/UseCase/ResourceUseCase/CommandResourceUseCase.php +++ b/src/Aplication/UseCase/ResourceUseCase/CommandResourceUseCase.php @@ -17,7 +17,9 @@ public function __construct( public function saveResources(): void { $this->sync('языки', [$this->databaseResources, 'getLanguages'], [$this->resourceSync, 'setLanguage']); - $this->sync('переводы', [$this->databaseResources, 'getTranslates'], [$this->resourceSync, 'setTranslation']); + $this->sync('переводы', [$this->databaseResources, 'getTranslates'], function ($translations) { + return $this->resourceSync->setTranslation('v1_translate_site', $translations); + }); $this->sync('планы', [$this->databaseResources, 'getPremiumPlans'], [$this->resourceSync, 'setPremiumPlans']); $this->sync('шаблоны привычек', [$this->databaseResources, 'getHabitsTemplates'], [$this->resourceSync, 'setHabitsTemplates']); $this->sync('FAQ', [$this->databaseResources, 'getFaq'], [$this->resourceSync, 'setFaq']); diff --git a/src/Domain/Service/ResourceService/ResourceSyncInterface.php b/src/Domain/Service/ResourceService/ResourceSyncInterface.php index cc47d19..f32b21c 100644 --- a/src/Domain/Service/ResourceService/ResourceSyncInterface.php +++ b/src/Domain/Service/ResourceService/ResourceSyncInterface.php @@ -18,7 +18,7 @@ public function setLanguage(array $languages): bool; /** * @param array>> $translations */ - public function setTranslation(array $translations): bool; + public function setTranslation(string $pageName, array $translations): bool; /** * @param PremiumPlansDto[] $plans diff --git a/src/Infrastructure/Repository/DataJunction/DataJunctionRepository.php b/src/Infrastructure/Repository/DataJunction/DataJunctionRepository.php index 9afda98..df4b73c 100644 --- a/src/Infrastructure/Repository/DataJunction/DataJunctionRepository.php +++ b/src/Infrastructure/Repository/DataJunction/DataJunctionRepository.php @@ -30,7 +30,7 @@ public function saveDateJunction(ReqDataJunction $data): int ->where('hdj.habitsId = :habitsId') ->andWhere('hdj.data_id = :dataId') ->andWhere('hdj.data_type = :dataType') - ->andWhere('hdj.is_delete = 0') + ->andWhere('hdj.is_delete = false') ->setParameter('habitsId', $data->getHabitsId()) ->setParameter('dataId', $data->getDataId()) ->setParameter('dataType', $data->getDataType()) @@ -57,7 +57,7 @@ public function updateDateJunction(int $habitsId, string $types): int|bool { $entity = $this->createQueryBuilder('hdj') ->where('hdj.habitsId = :habitsId') - ->andWhere('hdj.is_delete = 0') + ->andWhere('hdj.is_delete = false') ->setParameter('habitsId', $habitsId) ->getQuery() ->getOneOrNullResult(); @@ -89,7 +89,7 @@ public function getDateJunctionByHabitsId(int $habitsId): HabitsDataJuntion { $entity = $this->createQueryBuilder('hdj') ->where('hdj.habitsId = :habitsId') - ->andWhere('hdj.is_delete = 0') + ->andWhere('hdj.is_delete = false') ->setParameter('habitsId', $habitsId) ->getQuery() ->getOneOrNullResult(); @@ -110,7 +110,7 @@ public function getTypeByHabitsId(int $habitsId): string { $entity = $this->createQueryBuilder('djc') ->where('djc.habitsId = :habitsId') - ->andWhere('djc.is_delete = 0') + ->andWhere('djc.is_delete = false') ->setParameter('habitsId', $habitsId) ->getQuery() ->getOneOrNullResult(); @@ -131,7 +131,7 @@ public function updateType(int $habitsId, string $types): bool { $entity = $this->createQueryBuilder('djc') ->where('djc.habitsId = :habitsId') - ->andWhere('djc.is_delete = 0') + ->andWhere('djc.is_delete = false') ->setParameter('habitsId', $habitsId) ->getQuery() ->getOneOrNullResult(); @@ -155,7 +155,7 @@ public function createJunction(int $habitsId, string $types, int $dataId): int|b $exists = $this->createQueryBuilder('hdj') ->where('hdj.habitsId = :habitsId') - ->andWhere('hdj.is_delete = 0') + ->andWhere('hdj.is_delete = false') ->setParameter('habitsId', $habitsId) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/DatesDaily/DatesDailyRepository.php b/src/Infrastructure/Repository/DatesDaily/DatesDailyRepository.php index 835c802..9b9f452 100644 --- a/src/Infrastructure/Repository/DatesDaily/DatesDailyRepository.php +++ b/src/Infrastructure/Repository/DatesDaily/DatesDailyRepository.php @@ -41,7 +41,7 @@ public function updateDates(int $id, DatesDailyForSaveDto $dates): bool $em = $this->getEntityManager(); $datesEntity = $this->createQueryBuilder('d') ->where('d.id = :id') - ->andWhere('d.is_delete = 0') + ->andWhere('d.is_delete = false') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/DatesRepeat/DatesRepeatRepository.php b/src/Infrastructure/Repository/DatesRepeat/DatesRepeatRepository.php index baa9f2c..8c0dde3 100644 --- a/src/Infrastructure/Repository/DatesRepeat/DatesRepeatRepository.php +++ b/src/Infrastructure/Repository/DatesRepeat/DatesRepeatRepository.php @@ -34,7 +34,7 @@ public function updateDatesRepeat(int $id, int $day): bool $em = $this->getEntityManager(); $repeatEntity = $this->createQueryBuilder('r') ->where('r.id = :id') - ->andWhere('r.is_delete = 0') + ->andWhere('r.is_delete = false') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/DatesWeekly/DatesWeeklyRepository.php b/src/Infrastructure/Repository/DatesWeekly/DatesWeeklyRepository.php index caea1dd..b6aed0d 100644 --- a/src/Infrastructure/Repository/DatesWeekly/DatesWeeklyRepository.php +++ b/src/Infrastructure/Repository/DatesWeekly/DatesWeeklyRepository.php @@ -34,7 +34,7 @@ public function updateDatesWeekly(int $id, int $count): bool $em = $this->getEntityManager(); $weeklyEntity = $this->createQueryBuilder('w') ->where('w.id = :id') - ->andWhere('w.is_delete = 0') + ->andWhere('w.is_delete = false') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/Habits/HabitsHistoryRepository.php b/src/Infrastructure/Repository/Habits/HabitsHistoryRepository.php index 7cdadde..5757d82 100644 --- a/src/Infrastructure/Repository/Habits/HabitsHistoryRepository.php +++ b/src/Infrastructure/Repository/Habits/HabitsHistoryRepository.php @@ -70,7 +70,7 @@ public function getProgressToday(int $userId): array|false $results = $this->createQueryBuilder('h') ->where('h.userId = :userId') ->andWhere('h.recordedAt BETWEEN :start AND :end') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('userId', $userId) ->setParameter('start', $todayStart) ->setParameter('end', $todayEnd) @@ -100,7 +100,7 @@ public function getAllProgress(int $userId): array|false { $qb = $this->createQueryBuilder('h') ->where('h.userId = :userId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('userId', $userId) ->orderBy('h.recordedAt', 'ASC'); $results = $qb->getQuery()->getResult(); @@ -141,7 +141,7 @@ public function getAllProgressWithHabitsTitle(int $userId): array|false INNER JOIN habits h ON h.id = hh.habits_id WHERE hh.user_id = :userId AND hh.is_deleted = 0 - AND h.is_delete = 0 + AND h.is_delete = false ORDER BY hh.recorded_at ASC'; $results = $this->getEntityManager() @@ -172,7 +172,7 @@ public function getCountDoneHabits(int $userId): int ->select('COUNT(h.id)') ->where('h.userId = :userId') ->andWhere('h.isDone = 1') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('userId', $userId) ->getQuery() ->getSingleScalarResult(); diff --git a/src/Infrastructure/Repository/Habits/HabitsRepository.php b/src/Infrastructure/Repository/Habits/HabitsRepository.php index 3e4098d..08ce834 100644 --- a/src/Infrastructure/Repository/Habits/HabitsRepository.php +++ b/src/Infrastructure/Repository/Habits/HabitsRepository.php @@ -25,7 +25,7 @@ public function getByUserId(int $userId): Habit { return $this->createQueryBuilder('h') ->where('h.userId = :userId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('userId', $userId) ->getQuery() ->getResult(); @@ -138,7 +138,7 @@ public function getHabitsForToday(int $day, int $week, int $month, int $userId): ) AND h.begin_date <= :todayDate AND h.user_id = :userId - AND h.is_delete = 0 + AND h.is_delete = false "; $params = [ @@ -193,7 +193,7 @@ public function getCountHabitsToday(int $day, int $week, int $month, int $userId (dd.`{$dayOfWeek}` = TRUE OR dw.count_days = :dayOfWeekNumber OR dr.day = :dayOfMonth) AND h.begin_date <= :today AND h.user_id = :userId - AND h.is_delete = 0 + AND h.is_delete = false "; $params = [ diff --git a/src/Infrastructure/Repository/Language/LanguagePageRepositoru.php b/src/Infrastructure/Repository/Language/LanguagePageRepositoru.php index b8427ca..ab697b4 100644 --- a/src/Infrastructure/Repository/Language/LanguagePageRepositoru.php +++ b/src/Infrastructure/Repository/Language/LanguagePageRepositoru.php @@ -26,8 +26,8 @@ public function getPageTranslateByLangId(string $version, string $prefix): ?Lang ->join('lpt.language', 'lang') ->where('lpt.pageName = :page') ->andWhere('lang.prefix = :prefix') - ->andWhere('lpt.is_delete = 0') - ->andWhere('lang.is_delete = 0') + ->andWhere('lpt.is_delete = false') + ->andWhere('lang.is_delete = false') ->setParameter('page', $version) ->setParameter('prefix', $prefix) ->getQuery() diff --git a/src/Infrastructure/Repository/Matric/MatricColumnRepository.php b/src/Infrastructure/Repository/Matric/MatricColumnRepository.php index 6f96614..8708d57 100644 --- a/src/Infrastructure/Repository/Matric/MatricColumnRepository.php +++ b/src/Infrastructure/Repository/Matric/MatricColumnRepository.php @@ -25,7 +25,7 @@ public function renameMatricColumn(RenameColumnMatric $dto): bool $existing = $this->createQueryBuilder('m') ->where('m.userId = :userId') - ->andWhere('m.is_delete = 0') + ->andWhere('m.is_delete = false') ->setParameter('userId', $dto->userId) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/Matric/MatricJunctionRepository.php b/src/Infrastructure/Repository/Matric/MatricJunctionRepository.php index 7523fe2..a8064fb 100644 --- a/src/Infrastructure/Repository/Matric/MatricJunctionRepository.php +++ b/src/Infrastructure/Repository/Matric/MatricJunctionRepository.php @@ -43,8 +43,8 @@ public function getMatricWithTasks(int $userId, int $tasksId): MatricWithTasks|b LEFT JOIN tasksHistory th ON th.tasks_id = t.id WHERE m.user_id = :userId AND m.tasks_number = :tasksId - AND m.is_delete = 0 - AND t.is_delete = 0 + AND m.is_delete = false + AND t.is_delete = false '; $rows = $conn->fetchAllAssociative($sql, [ diff --git a/src/Infrastructure/Repository/Pomdor/PomodorHistoryRepository.php b/src/Infrastructure/Repository/Pomdor/PomodorHistoryRepository.php index d5a7897..297037c 100644 --- a/src/Infrastructure/Repository/Pomdor/PomodorHistoryRepository.php +++ b/src/Infrastructure/Repository/Pomdor/PomodorHistoryRepository.php @@ -94,7 +94,7 @@ public function getDataByUserIdAndPeriod(int $userId, int $target): array return $this->createQueryBuilder('h') ->andWhere('h.user_id = :userId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->andWhere('h.create_date BETWEEN :start AND :end') ->setParameter('userId', $userId) ->setParameter('start', $start) @@ -114,7 +114,7 @@ public function getPomoDayByUserId(int $userId): array return $this->createQueryBuilder('h') ->andWhere('h.user_id = :userId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->andWhere('h.create_date BETWEEN :start AND :end') ->setParameter('userId', $userId) ->setParameter('start', $start) @@ -130,7 +130,7 @@ public function getAllCountPomodorByUserId(int $userId): int|bool return (int) $this->createQueryBuilder('h') ->select('COUNT(h.id)') ->andWhere('h.user_id = :userId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('userId', $userId) ->getQuery() ->getSingleScalarResult(); diff --git a/src/Infrastructure/Repository/Purpose/PurposeRepository.php b/src/Infrastructure/Repository/Purpose/PurposeRepository.php index c9c0fcf..feb4c73 100644 --- a/src/Infrastructure/Repository/Purpose/PurposeRepository.php +++ b/src/Infrastructure/Repository/Purpose/PurposeRepository.php @@ -41,7 +41,7 @@ public function updatePurposeByHabitId(PurposeDto $dto): bool $em = $this->getEntityManager(); $purpose = $this->createQueryBuilder('p') ->where('p.habitsId = :habitsId') - ->andWhere('p.is_delete = 0') + ->andWhere('p.is_delete = false') ->setParameter('habitsId', $dto->getHabitsId()) ->getQuery() ->getOneOrNullResult(); @@ -67,7 +67,7 @@ public function getPurposeCountByHabitId(int $habitId): int return (int) $this->createQueryBuilder('h') ->select('h.count') ->where('h.habitsId = :habitId') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('habitId', $habitId) ->getQuery() ->getSingleScalarResult(); @@ -78,7 +78,7 @@ public function deletePurposeByHabitId(int $habitId): bool $em = $this->getEntityManager(); $purpose = $this->createQueryBuilder('p') ->where('p.habitsId = :habitId') - ->andWhere('p.is_delete = 0') + ->andWhere('p.is_delete = false') ->setParameter('habitId', $habitId) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Repository/Storage/StorageRepository.php b/src/Infrastructure/Repository/Storage/StorageRepository.php index 0fb4644..e5492a6 100644 --- a/src/Infrastructure/Repository/Storage/StorageRepository.php +++ b/src/Infrastructure/Repository/Storage/StorageRepository.php @@ -28,7 +28,7 @@ public function saveStorage(SaveStorageDto $saveStorageDto): int|false ->where('h.fullPath = :fullPath') ->andWhere('h.type = :type') ->andWhere('h.fileType = :fileType') - ->andWhere('h.is_delete = 0') + ->andWhere('h.is_delete = false') ->setParameter('fullPath', $saveStorageDto->fullPath) ->setParameter('type', $saveStorageDto->type) ->setParameter('fileType', $saveStorageDto->fileType) diff --git a/src/Infrastructure/Repository/Tasks/TasksRepository.php b/src/Infrastructure/Repository/Tasks/TasksRepository.php index e3b8781..e76757b 100644 --- a/src/Infrastructure/Repository/Tasks/TasksRepository.php +++ b/src/Infrastructure/Repository/Tasks/TasksRepository.php @@ -111,7 +111,7 @@ public function getTasksByDay(int $userId, int $day): array $qb = $this->createQueryBuilder('t') ->leftJoin('App\Domain\Entity\Tasks\TasksHistory', 'th', 'WITH', 'th.tasks_id = t.id') ->where('t.userId = :userId') - ->andWhere('t.is_delete = 0') + ->andWhere('t.is_delete = false') ->andWhere('( (t.beginDate IS NOT NULL AND t.beginDate <= :fullDate) OR ( @@ -167,7 +167,7 @@ public function getTasksAllByUserId(int $userId): array ->select('t', 'th.id AS historyId') ->leftJoin('App\Domain\Entity\Tasks\TasksHistory', 'th', 'WITH', 'th.tasks_id = t.id') ->where('t.userId = :userId') - ->andWhere('t.is_delete = 0') + ->andWhere('t.is_delete = false') ->setParameter('userId', $userId); /** @var array, historyId?: int|null}> $result */ diff --git a/src/Infrastructure/Repository/UsersRepository.php b/src/Infrastructure/Repository/UsersRepository.php index dc5ff13..8a54031 100644 --- a/src/Infrastructure/Repository/UsersRepository.php +++ b/src/Infrastructure/Repository/UsersRepository.php @@ -26,7 +26,7 @@ public function findByEmail(string $email): Users|bool { $user = $this->createQueryBuilder('u') ->where('u.email = :email') - ->andWhere('u.is_delete = 0') + ->andWhere('u.is_delete = false') ->setParameter('email', $email) ->getQuery() ->getOneOrNullResult(); @@ -40,7 +40,7 @@ public function findById(int $id): Users|bool { $user = $this->createQueryBuilder('u') ->where('u.id = :id') - ->andWhere('u.is_delete = 0') + ->andWhere('u.is_delete = false') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult(); diff --git a/src/Infrastructure/Service/ResourceService/ResourceSyncService.php b/src/Infrastructure/Service/ResourceService/ResourceSyncService.php index 08e1488..ce3361a 100644 --- a/src/Infrastructure/Service/ResourceService/ResourceSyncService.php +++ b/src/Infrastructure/Service/ResourceService/ResourceSyncService.php @@ -50,37 +50,31 @@ public function setLanguage(array $languages): bool /** * @param array>> $translations */ - public function setTranslation(array $translations): bool + public function setTranslation(string $pageName, array $translations): bool { $languages = $this->manager->getRepository(Language::class)->findAll(); - $languagesByPrefix = []; - foreach ($languages as $lang) { - $languagesByPrefix[$lang->getPrefix()] = $lang; - } - foreach ($translations as $pageName => $pageTranslations) { - foreach ($languagesByPrefix as $prefix => $language) { - if (!$language) { - continue; - } - $pageTranslate = $this->extractTranslationsForLanguage($pageTranslations, $prefix); - - $existing = $this->manager->getRepository(LanguagePageTranslation::class) - ->findOneBy([ - 'pageName' => $pageName, - 'language' => $language, - ]); + foreach ($languages as $language) { + if (!$language) { + continue; + } - if ($existing) { - $existing->setPageTranslate($pageTranslate); - } else { - $translation = new LanguagePageTranslation(); - $translation->setPageName($pageName); - $translation->setPageTranslate($pageTranslate); - $translation->setLanguage($language); + $pageTranslate = $this->extractTranslationsForLanguage($translations, $language->getPrefix()); + $existing = $this->manager->getRepository(LanguagePageTranslation::class) + ->findOneBy([ + 'pageName' => $pageName, + 'language' => $language, + ]); - $this->manager->persist($translation); - } + if ($existing) { + $existing->setPageTranslate($pageTranslate); + } else { + $translation = new LanguagePageTranslation(); + $translation->setPageName($pageName); + $translation->setPageTranslate($pageTranslate); + $translation->setLanguage($language); + + $this->manager->persist($translation); } }