Skip to content

Commit

Permalink
removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
tito10047 committed Sep 24, 2024
1 parent cebfa3c commit 463a108
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 161 deletions.
52 changes: 0 additions & 52 deletions src/Repository/ProjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,4 @@ public function __construct(ManagerRegistry $registry) {
parent::__construct($registry, Project::class);
}

public function save(Project $entity, bool $flush = false): void {
$this->getEntityManager()->persist($entity);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function remove(Project $entity, bool $flush = false): void {
$this->getEntityManager()->remove($entity);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function createEmpty(bool $flush): Project {
$entity = new Project();

$this->save($entity, $flush);

return $entity;
}

public function getQBWith(?bool $enabled = null): QueryBuilder {
$qb = $this->createQueryBuilder('p');

if ($enabled !== null) {
$qb->andWhere('p.enabled = :enabled')->setParameter('enabled', $enabled);
}

return $qb;
}

public function getQBBlank(): QueryBuilder {
return $this->createQueryBuilder('p')->setMaxResults(0);
}

/**
* @param User|null $user
* @return array<Project>
*/
public function findByAdmin(?User $user): array {
$qb = $this->createQueryBuilder('p');
$qb
->join("p.users", "u")
->where('u.id = :admin')
->setParameter('admin', $user->getId(), UuidType::NAME);

return $qb->getQuery()->getResult();
}

}
35 changes: 0 additions & 35 deletions src/Repository/RecordLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,6 @@ public function __construct(
parent::__construct($registry, RecordLog::class);
}

public function save(Record $entity, bool $flush = false): void {
$this->getEntityManager()->persist($entity);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function remove(Record $entity, bool $flush = false): void {
$this->getEntityManager()->remove($entity);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function createEmpty(bool $flush): Record {
$entity = new RecordLog();

$this->save($entity, $flush);

return $entity;
}

public function getQBWith(): QueryBuilder {
$qb = $this->createQueryBuilder('l');

return $qb;
}

public function getQBBlank(): QueryBuilder {
return $this->createQueryBuilder('l')->setMaxResults(0);
}


public function setStatusBetween(
array $projects,
DateTimeInterface $from,
Expand Down
37 changes: 1 addition & 36 deletions src/Repository/RecordLogWithholderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,12 @@
* @method RecordLogWithholder[] findAll()
* @method RecordLogWithholder[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
final class RecordLogWithholderRepository extends ServiceEntityRepository implements RecordRepositoryInterface
final class RecordLogWithholderRepository extends ServiceEntityRepository
{
public function __construct(
ManagerRegistry $registry,
private readonly RecordRepositoryInterface $recordRepository,
) {
parent::__construct($registry, RecordLogWithholder::class);
}

public function setStatusBetween(
array $projects,
DateTimeInterface $from,
DateTimeInterface $to,
string $newStatus,
string $previousStatus = 'new',
callable $qbCreator = null
): void {
$this->recordRepository->setStatusBetween(
$projects,
$from, $to,
$newStatus,
$previousStatus,
$qbCreator
);
}

public function setStatus(
Record $log,
DateTimeInterface $lastDate,
string $newStatus,
string $previousStatus = 'new',
bool $flush = false,
callable $qbCreator = null
) {
$this->recordRepository->setStatus(
$log,
$lastDate,
$newStatus,
$previousStatus,
$flush,
$qbCreator
);
}
}
29 changes: 0 additions & 29 deletions src/Repository/RecordPingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,8 @@ public function save(RecordPing $entity, bool $flush = false): void
}
}

public function remove(RecordPing $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function createEmpty(bool $flush): RecordPing
{
$entity = new RecordPing();

$this->save($entity, $flush);

return $entity;
}

public function getQBWith(Project $project): QueryBuilder
{
$qb = $this->createQueryBuilder('r');

$qb->andWhere('r.project = :project')
->setParameter('project', $project->getId(), UuidType::NAME);

return $qb;
}

public function getLastRecord(Project $project, string $maxLife = '-1 hour'): ?RecordPing
{
Expand All @@ -79,10 +54,6 @@ public function getLastRecord(Project $project, string $maxLife = '-1 hour'): ?R
->getOneOrNullResult();
}

public function getQBBlank(): QueryBuilder
{
return $this->createQueryBuilder('p')->setMaxResults(0);
}

public function setStatusBetween(
array $projects,
Expand Down
9 changes: 0 additions & 9 deletions src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,4 @@ public function save(User $entity, bool $flush = false): void {
}
}

public function getQBWith(): QueryBuilder {
$qb = $this->createQueryBuilder('u');

return $qb;
}

public function getQBBlank(): QueryBuilder {
return $this->createQueryBuilder('u')->setMaxResults(0);
}
}

0 comments on commit 463a108

Please sign in to comment.