feat: surface stuck booking edits to customer experts
This commit is contained in:
1 parent
a1d1fdde14
commit
019de4e705
4 files changed
+215
No files matched your search
@@ -123,4 +123,35 @@ class BookingEditDraftRepository extends ServiceEntityRepository
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds drafts whose owner has been unable to save for a while.
|
||||
*
|
||||
* A draft is deleted the moment an update succeeds (see BookingEditSubmitter), so its mere age
|
||||
* is the signal: one that has survived for days belongs to somebody whose changes BusPro keeps
|
||||
* refusing. Drafts for departed travels are excluded - nothing can be done about those, and the
|
||||
* nightly cleanup removes them anyway.
|
||||
*
|
||||
* Ordered by the most recent attempt rather than by age: somebody who tried again yesterday is
|
||||
* still stuck and still waiting, while the oldest drafts are mostly edits abandoned months ago.
|
||||
* Sorting by age alone fills the list with the latter and buries the people to help.
|
||||
*
|
||||
* @param int $minAgeDays How long a draft must have existed to count as stuck
|
||||
*
|
||||
* @return BookingEditDraft[] Most recently attempted first
|
||||
*/
|
||||
public function findStuck(int $minAgeDays = 7, int $limit = 10): array
|
||||
{
|
||||
return $this->createQueryBuilder('d')
|
||||
->join('d.user', 'u')
|
||||
->addSelect('u')
|
||||
->where('d.createdAt < :cutoff')
|
||||
->andWhere('d.travelDate >= :today')
|
||||
->setParameter('cutoff', new \DateTimeImmutable(sprintf('-%d days', $minAgeDays)))
|
||||
->setParameter('today', new \DateTimeImmutable('today'))
|
||||
->orderBy('d.updatedAt', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user