public function getClientDataBySerializedDataJsonKey(string $keyName, string $keyValue, int $penultimateStep) :?MultiStepFormClientData {
$createdAtCondition = new \DateTime('now -30 days');
$query = $this->createQueryBuilder('cd')
->where('cd.createdAt > :createdAt')
->andWhere('cd.stepNr = :stepNr')
->andWhere('cd.status = :status')
->andWhere("JSON_CONTAINS(cd.serializedData, :keyName, '$.".$keyName."') = 1");
$query->setParameter('createdAt', $createdAtCondition);
$query->setParameter('stepNr', $penultimateStep);
$query->setParameter('status', ClientStatuses::TYPE_COMPLETED);
$query->setParameter('keyName', '"'.$keyValue.'"');
$query->orderBy('cd.createdAt', 'DESC')->setMaxResults(1);
return $query->getQuery()->getOneOrNullResult();
}
//wymaga