performance improvements (#927)

This commit is contained in:
Kevin Papst
2019-07-09 03:40:48 +02:00
committed by GitHub
parent eb4aa23577
commit cbf9086e10
15 changed files with 172 additions and 85 deletions

View File

@@ -15,8 +15,18 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="kimai2_activities")
* @ORM\Table(name="kimai2_activities",
* indexes={
* @ORM\Index(columns={"visible","project_id"}),
* @ORM\Index(columns={"visible","project_id","name"}),
* @ORM\Index(columns={"visible","name"})
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\ActivityRepository")
*
* columns={"visible","name"} => IDX_8811FE1C7AB0E8595E237E06 => activity administration without filter
* columns={"visible","project_id"} => IDX_8811FE1C7AB0E859166D1F9C => activity administration with customer or project filter
* columns={"visible","project_id","name"} => IDX_8811FE1C7AB0E859166D1F9C5E237E06 => activity drop-down for global activities in toolbar or globalsOnly filter in activity administration
*/
class Activity implements EntityWithMetaFields
{
@@ -32,7 +42,7 @@ class Activity implements EntityWithMetaFields
/**
* @var Project|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="activities")
* @ORM\ManyToOne(targetEntity="App\Entity\Project")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $project;
@@ -61,13 +71,6 @@ class Activity implements EntityWithMetaFields
*/
private $visible = true;
/**
* @var Timesheet[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\Timesheet", mappedBy="activity")
*/
private $timesheets;
// keep the trait include exactly here, for placing the column at the correct position
use RatesTrait;
use ColorTrait;
@@ -82,7 +85,6 @@ class Activity implements EntityWithMetaFields
public function __construct()
{
$this->timesheets = new ArrayCollection();
$this->meta = new ArrayCollection();
}
@@ -91,14 +93,6 @@ class Activity implements EntityWithMetaFields
return $this->id;
}
/**
* @return Collection<Timesheet>
*/
public function getTimesheets(): Collection
{
return $this->timesheets;
}
public function getProject(): ?Project
{
return $this->project;

View File

@@ -30,7 +30,7 @@ class ActivityMeta implements MetaTableTypeInterface
* @var Activity
*
* @ORM\ManyToOne(targetEntity="App\Entity\Activity", inversedBy="meta")
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
private $activity;

View File

@@ -27,7 +27,7 @@ trait BudgetTrait
*
* @var int
*
* @ORM\Column(name="time_budget", type="integer", precision=10, scale=2, nullable=false)
* @ORM\Column(name="time_budget", type="integer", nullable=false)
* @Assert\NotNull()
*/
private $timeBudget = 0;

View File

@@ -15,8 +15,14 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="kimai2_customers")
* @ORM\Table(name="kimai2_customers",
* indexes={
* @ORM\Index(columns={"visible"})
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
*
* columns={"visible"} => IDX_5A9760447AB0E859 => used in customer dropdown
*/
class Customer implements EntityWithMetaFields
{
@@ -54,13 +60,6 @@ class Customer implements EntityWithMetaFields
*/
private $comment;
/**
* @var Project[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\Project", mappedBy="customer")
*/
private $projects;
/**
* @var bool
*
@@ -163,7 +162,6 @@ class Customer implements EntityWithMetaFields
public function __construct()
{
$this->projects = new ArrayCollection();
$this->meta = new ArrayCollection();
}
@@ -352,14 +350,6 @@ class Customer implements EntityWithMetaFields
return $this->timezone;
}
/**
* @return Collection<Project>
*/
public function getProjects(): Collection
{
return $this->projects;
}
/**
* @internal only here for symfony forms
* @return Collection|MetaTableTypeInterface[]

View File

@@ -30,7 +30,7 @@ class CustomerMeta implements MetaTableTypeInterface
* @var Customer
*
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="meta")
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
private $customer;

View File

@@ -44,7 +44,7 @@ trait MetaTableTypeTrait
/**
* @var bool
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @ORM\Column(name="visible", type="boolean", nullable=false, options={"default": false})
* @Assert\NotNull()
*/
private $visible = false;

View File

@@ -15,8 +15,16 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="kimai2_projects")
* @ORM\Table(name="kimai2_projects",
* indexes={
* @ORM\Index(columns={"customer_id","visible","name"}),
* @ORM\Index(columns={"customer_id","visible","id"})
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
*
* columns={"customer_id","visible","name"} => IDX_407F12069395C3F37AB0E8595E237E06 => project administration without filter
* columns={"customer_id","visible","id"} => IDX_407F12069395C3F37AB0E859BF396750 => used in joins between project and customer, eg. dropdowns and activity administration page
*/
class Project implements EntityWithMetaFields
{
@@ -32,7 +40,7 @@ class Project implements EntityWithMetaFields
/**
* @var Customer
*
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="projects")
* @ORM\ManyToOne(targetEntity="App\Entity\Customer")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
@@ -70,25 +78,11 @@ class Project implements EntityWithMetaFields
*/
private $visible = true;
/**
* @var Activity[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\Activity", mappedBy="project")
*/
private $activities;
// keep the trait include exactly here, for placing the column at the correct position
use RatesTrait;
use ColorTrait;
use BudgetTrait;
/**
* @var Timesheet[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\Timesheet", mappedBy="project")
*/
private $timesheets;
/**
* @var ProjectMeta[]|Collection
*
@@ -98,8 +92,6 @@ class Project implements EntityWithMetaFields
public function __construct()
{
$this->activities = new ArrayCollection();
$this->timesheets = new ArrayCollection();
$this->meta = new ArrayCollection();
}
@@ -163,22 +155,6 @@ class Project implements EntityWithMetaFields
return $this->visible;
}
/**
* @return Collection<Timesheet>
*/
public function getTimesheets(): Collection
{
return $this->timesheets;
}
/**
* @return Collection<Activity>
*/
public function getActivities(): Collection
{
return $this->activities;
}
/**
* @return string|null
*/

View File

@@ -30,7 +30,7 @@ class ProjectMeta implements MetaTableTypeInterface
* @var Project
*
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="meta")
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
private $project;

View File

@@ -18,12 +18,23 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table(name="kimai2_timesheet",
* indexes={
* @ORM\Index(columns={"user"}),
* @ORM\Index(columns={"activity_id"})
* @ORM\Index(columns={"activity_id"}),
* @ORM\Index(columns={"user","start_time"}),
* @ORM\Index(columns={"start_time"}),
* @ORM\Index(columns={"start_time","end_time"}),
* @ORM\Index(columns={"start_time","end_time","user"}),
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\TimesheetRepository")
* @ORM\HasLifecycleCallbacks()
* @App\Validator\Constraints\Timesheet
*
* columns={"user"} => IDX_4F60C6B18D93D649 => count results for user timesheets
* columns={"activity_id"} => IDX_4F60C6B181C06096 => ???
* columns={"user","start_time"} => IDX_4F60C6B18D93D649502DF587 => recent activities, user timesheet with date filzer
* columns={"start_time"} => IDX_4F60C6B1502DF587 => team timesheets with timerange filter only
* columns={"start_time","end_time"} => IDX_4F60C6B1502DF58741561401 => ???
* columns={"start_time","end_time","user"} => IDX_4F60C6B1502DF587415614018D93D649 => ???
*/
class Timesheet implements EntityWithMetaFields
{
@@ -83,7 +94,7 @@ class Timesheet implements EntityWithMetaFields
/**
* @var Activity
*
* @ORM\ManyToOne(targetEntity="App\Entity\Activity", inversedBy="timesheets")
* @ORM\ManyToOne(targetEntity="App\Entity\Activity")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
@@ -92,7 +103,7 @@ class Timesheet implements EntityWithMetaFields
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="timesheets")
* @ORM\ManyToOne(targetEntity="App\Entity\Project")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/

View File

@@ -30,7 +30,7 @@ class TimesheetMeta implements MetaTableTypeInterface
* @var Timesheet
*
* @ORM\ManyToOne(targetEntity="App\Entity\Timesheet", inversedBy="meta")
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull()
*/
private $timesheet;