Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Demo] Init dashboard statistics #238

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

loic425
Copy link
Member

@loic425 loic425 commented Feb 14, 2025

Based on #237

dashboard_statistics_demo.webm

@@ -61,6 +63,14 @@ class Speaker implements ResourceInterface
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?SpeakerAvatar $avatar = null;

#[ORM\ManyToMany(targetEntity: Talk::class, mappedBy: 'speakers')]
private Collection $talks;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be there getters/setters for this collection?

@@ -26,4 +26,23 @@ public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Conference::class);
}

public function findTotalConferences(\DatePeriod $datePeriod): int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nitpick, would be cool to follow sylius/core-bundle notation as in example.

https://github.com/Sylius/Sylius/blob/6c24de65903247056abffc1dfc1b77f10fe249b2/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php#L253

Suggested change
public function findTotalConferences(\DatePeriod $datePeriod): int
public function getTotalConferences(\DatePeriod $datePeriod): int

Comment on lines +32 to +35
$queryBuilder = $this->createQueryBuilder('o');

$queryBuilder
->select('COUNT(o.id)')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$queryBuilder = $this->createQueryBuilder('o');
$queryBuilder
->select('COUNT(o.id)')
return (int) $this->createQueryBuilder('o')
->select('COUNT(o.id)')

Comment on lines +37 to +43
$queryBuilder->expr()->gte('o.startsAt', ':start_date'),
)
->andWhere(
$queryBuilder->expr()->lt('o.startsAt', ':end_date'),
)
->setParameter('start_date', $datePeriod->getStartDate())
->setParameter('end_date', $datePeriod->getEndDate())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more common within sylius to use camelCase for parameters.

Suggested change
$queryBuilder->expr()->gte('o.startsAt', ':start_date'),
)
->andWhere(
$queryBuilder->expr()->lt('o.startsAt', ':end_date'),
)
->setParameter('start_date', $datePeriod->getStartDate())
->setParameter('end_date', $datePeriod->getEndDate())
$queryBuilder->expr()->gte('o.startsAt', ':startDate'),
)
->andWhere(
$queryBuilder->expr()->lt('o.startsAt', ':endDate'),
)
->setParameter('startDate', $datePeriod->getStartDate())
->setParameter('endDate', $datePeriod->getEndDate())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments for other repository methods.

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

public function findTotalTalks(\DatePeriod $datePeriod): int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- findTotalTalks
+++ findTotalSpeakers
Suggested change
public function findTotalTalks(\DatePeriod $datePeriod): int
public function getTotalSpeakers(\DatePeriod $datePeriod): int
Suggested change
public function findTotalTalks(\DatePeriod $datePeriod): int
public function getTotalSpeakersWithTalksInPeriod(\DatePeriod $datePeriod): int

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

public function findTotalTalks(\DatePeriod $datePeriod): int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function findTotalTalks(\DatePeriod $datePeriod): int
public function getTotalTalks(\DatePeriod $datePeriod): int

Comment on lines +33 to +38
day: Jour
lifetime: Durée de vie
month: Mois
week: Semaine
2weeks: 2 Semaines
year: Année
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is english translation file, please translate 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants