This commit is contained in:
Marek Lenczewski
2026-03-31 17:13:10 +02:00
parent 576bfed36d
commit b6a4548732
13 changed files with 99 additions and 36 deletions

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260331120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove categoryOverridden: backfill task.category_id from schema, then drop column';
}
public function up(Schema $schema): void
{
$this->addSql('UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.category_id = ts.category_id WHERE t.category_overridden = 0');
$this->addSql('ALTER TABLE task DROP category_overridden');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE task ADD category_overridden TINYINT(1) NOT NULL DEFAULT 0');
}
}

56
backend/plan2.md Normal file
View File

@@ -0,0 +1,56 @@
# Backend
## Task
- Wird verwendet um Aufgaben anzuzeigen
- Entity
- name - Name der Aufgabe
- status - Status (active, done), null is disabled
- date - Deadline, null for no deadline
- schema - schemaId, null no schema
- category - categoryId, null no category
- Controller
- index() - Alle Tasks zurückgeben
- show(id) - Ein Task zurückgeben
- create() - Task erstellen
- update(id) - Task aktualisieren
- delete(id) - Task entfernen
- Werden durch Schemas erstellt
-
## Category
- Kategorien die von Aufgaben und Schemas verwendet werden
- Entity
- name - Kategoriename
- color - Hex-Farbe
- Controller
- index() - Alle Kategorien zurückgeben
- show(id) - Eine Kategorie zurückgeben
- create() - Kategorie erstellen
- update(id) - Kategorie aktualisieren
- delete(id) - Kategorie entfernen
## Schema
- Template um Aufgaben zu erstellen
- Entity
- name - Name für erstellte Aufgaben
- status - Status für erstellte Aufgaben
- category - Kategorie für erstellte Aufgaben
- type
- single - Einmal erstellt, schema = null
- repeat - Wiederholt erstellt, schema = id
- start - Startdatum für type=repeat
- end - Enddatum für type=repeat
- days - Tage für Muster für die Erstellung der Aufgaben
- week - Array für Wochentage (1-7)
- month - Array für Monatstage (1-31)
- year - Array für Jahrestage (1-365/366)
- Controller
- index() - Alle Schema zurückgeben
- show(id) - Eine Schema zurückgeben
- create() - Schema erstellen
- update(id) - Schema aktualisieren
- delete(id) - Schema entfernen
- Anpasung -> Alle Tasks anpassen (keine Vergangenheit)

View File

@@ -34,9 +34,6 @@ class Task
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?Category $category = null; private ?Category $category = null;
#[ORM\Column]
private bool $categoryOverridden = false;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)] #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null; private ?\DateTimeInterface $date = null;
@@ -82,6 +79,7 @@ class Task
return $this; return $this;
} }
#[Groups(['task:read'])]
public function getCategory(): ?Category public function getCategory(): ?Category
{ {
return $this->category; return $this->category;
@@ -93,17 +91,6 @@ class Task
return $this; return $this;
} }
public function isCategoryOverridden(): bool
{
return $this->categoryOverridden;
}
public function setCategoryOverridden(bool $categoryOverridden): static
{
$this->categoryOverridden = $categoryOverridden;
return $this;
}
#[Groups(['task:read'])] #[Groups(['task:read'])]
#[SerializedName('name')] #[SerializedName('name')]
public function getEffectiveName(): string public function getEffectiveName(): string
@@ -111,13 +98,6 @@ class Task
return $this->name ?? $this->schema->getName(); return $this->name ?? $this->schema->getName();
} }
#[Groups(['task:read'])]
#[SerializedName('category')]
public function getEffectiveCategory(): ?Category
{
return $this->categoryOverridden ? $this->category : $this->schema->getCategory();
}
#[Groups(['task:read'])] #[Groups(['task:read'])]
public function getDate(): ?\DateTimeInterface public function getDate(): ?\DateTimeInterface
{ {

View File

@@ -37,7 +37,7 @@ class TaskRepository extends ServiceEntityRepository
{ {
return $this->createQueryBuilder('task') return $this->createQueryBuilder('task')
->join('task.schema', 'schema') ->join('task.schema', 'schema')
->leftJoin('schema.category', 'category') ->leftJoin('task.category', 'category')
->addSelect('schema', 'category') ->addSelect('schema', 'category')
->where('task.date >= :from') ->where('task.date >= :from')
->andWhere('task.date <= :to') ->andWhere('task.date <= :to')
@@ -122,7 +122,7 @@ class TaskRepository extends ServiceEntityRepository
{ {
return $this->createQueryBuilder('task') return $this->createQueryBuilder('task')
->join('task.schema', 'schema') ->join('task.schema', 'schema')
->leftJoin('schema.category', 'category') ->leftJoin('task.category', 'category')
->addSelect('schema', 'category') ->addSelect('schema', 'category')
->where('task.date IS NOT NULL') ->where('task.date IS NOT NULL')
->orderBy('task.date', 'DESC') ->orderBy('task.date', 'DESC')
@@ -137,7 +137,7 @@ class TaskRepository extends ServiceEntityRepository
{ {
return $this->createQueryBuilder('task') return $this->createQueryBuilder('task')
->join('task.schema', 'schema') ->join('task.schema', 'schema')
->leftJoin('schema.category', 'category') ->leftJoin('task.category', 'category')
->addSelect('schema', 'category') ->addSelect('schema', 'category')
->where('task.date IS NULL') ->where('task.date IS NULL')
->andWhere('schema.status != :excluded') ->andWhere('schema.status != :excluded')

View File

@@ -34,6 +34,7 @@ class TaskGenerator
$task = new Task(); $task = new Task();
$task->setSchema($schema); $task->setSchema($schema);
$task->setDate(new \DateTime($deadline->format('Y-m-d'))); $task->setDate(new \DateTime($deadline->format('Y-m-d')));
$task->setCategory($schema->getCategory());
$this->em->persist($task); $this->em->persist($task);
$existingKeys[$key] = true; $existingKeys[$key] = true;
@@ -63,6 +64,7 @@ class TaskGenerator
$task = new Task(); $task = new Task();
$task->setSchema($schema); $task->setSchema($schema);
$task->setDate(null); $task->setDate(null);
$task->setCategory($schema->getCategory());
$this->em->persist($task); $this->em->persist($task);
$hasNew = true; $hasNew = true;
} }

View File

@@ -30,7 +30,6 @@ class TaskManager
? $this->categoryRepository->find($request->categoryId) ? $this->categoryRepository->find($request->categoryId)
: null; : null;
$task->setCategory($category); $task->setCategory($category);
$task->setCategoryOverridden(true);
$status = TaskStatus::tryFrom($request->status); $status = TaskStatus::tryFrom($request->status);
if ($status !== null) { if ($status !== null) {

View File

@@ -82,8 +82,7 @@ class TaskSynchronizer
if ($schema->getTaskType() === TaskSchemaType::Single && $schema->getDeadline() === null) { if ($schema->getTaskType() === TaskSchemaType::Single && $schema->getDeadline() === null) {
foreach ($nullDateTasks as $task) { foreach ($nullDateTasks as $task) {
$task->setName(null); $task->setName(null);
$task->setCategory(null); $task->setCategory($schema->getCategory());
$task->setCategoryOverridden(false);
} }
} else { } else {
foreach ($nullDateTasks as $task) { foreach ($nullDateTasks as $task) {
@@ -99,8 +98,7 @@ class TaskSynchronizer
{ {
foreach ($existingByDate as $task) { foreach ($existingByDate as $task) {
$task->setName(null); $task->setName(null);
$task->setCategory(null); $task->setCategory($task->getSchema()->getCategory());
$task->setCategoryOverridden(false);
} }
} }
@@ -116,6 +114,7 @@ class TaskSynchronizer
$task = new Task(); $task = new Task();
$task->setSchema($schema); $task->setSchema($schema);
$task->setDate(new \DateTime($dateKey)); $task->setDate(new \DateTime($dateKey));
$task->setCategory($schema->getCategory());
$this->em->persist($task); $this->em->persist($task);
} }

View File

@@ -16,7 +16,7 @@ if (!\class_exists(App_KernelDevDebugContainer::class, false)) {
return new \Container9vrsx4S\App_KernelDevDebugContainer([ return new \Container9vrsx4S\App_KernelDevDebugContainer([
'container.build_hash' => '9vrsx4S', 'container.build_hash' => '9vrsx4S',
'container.build_id' => 'de48fc05', 'container.build_id' => '109f11e1',
'container.build_time' => 1774939296, 'container.build_time' => 1774968178,
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1', 'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
], __DIR__.\DIRECTORY_SEPARATOR.'Container9vrsx4S'); ], __DIR__.\DIRECTORY_SEPARATOR.'Container9vrsx4S');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
a:0:{} a:2:{i:0;a:6:{s:4:"type";i:16384;s:7:"message";s:255:"The "use_savepoints" configuration key is deprecated when using DBAL 4 and will be removed in DoctrineBundle 3.0. (Configuration.php:397 called by ExprBuilder.php:271, https://github.com/doctrine/DoctrineBundle/pull/2055, package doctrine/doctrine-bundle)";s:4:"file";s:70:"/var/www/html/backend/vendor/doctrine/deprecations/src/Deprecation.php";s:4:"line";i:208;s:5:"trace";a:1:{i:0;a:5:{s:4:"file";s:70:"/var/www/html/backend/vendor/doctrine/deprecations/src/Deprecation.php";s:4:"line";i:108;s:8:"function";s:24:"delegateTriggerToBackend";s:5:"class";s:33:"Doctrine\Deprecations\Deprecation";s:4:"type";s:2:"::";}}s:5:"count";i:1;}i:1;a:6:{s:4:"type";i:16384;s:7:"message";s:322:"The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0. When using ORM 3, report_fields_where_declared will always be true. (Configuration.php:701 called by ExprBuilder.php:271, https://github.com/doctrine/DoctrineBundle/pull/1962, package doctrine/doctrine-bundle)";s:4:"file";s:70:"/var/www/html/backend/vendor/doctrine/deprecations/src/Deprecation.php";s:4:"line";i:208;s:5:"trace";a:1:{i:0;a:5:{s:4:"file";s:70:"/var/www/html/backend/vendor/doctrine/deprecations/src/Deprecation.php";s:4:"line";i:108;s:8:"function";s:24:"delegateTriggerToBackend";s:5:"class";s:33:"Doctrine\Deprecations\Deprecation";s:4:"type";s:2:"::";}}s:5:"count";i:1;}}