retapage accueil, gestion de Demandes

This commit is contained in:
Tykayn 2025-07-16 17:00:09 +02:00 committed by tykayn
parent d777221d0d
commit f4c5e048ff
26 changed files with 2498 additions and 292 deletions

View file

@ -16,28 +16,20 @@ class CityFollowUpRepository extends ServiceEntityRepository
parent::__construct($registry, CityFollowUp::class);
}
// /**
// * @return CityFollowUp[] Returns an array of CityFollowUp objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?CityFollowUp
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
public function findRecentByStatsAndName(Stats $stats, string $name, \DateTime $since): ?CityFollowUp
{
return $this->createQueryBuilder('c')
->andWhere('c.stats = :stats')
->andWhere('c.name = :name')
->andWhere('c.date >= :since')
->setParameter('stats', $stats)
->setParameter('name', $name)
->setParameter('since', $since)
->orderBy('c.date', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
;
}
}

View file

@ -0,0 +1,99 @@
<?php
namespace App\Repository;
use App\Entity\Demande;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Demande>
*/
class DemandeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Demande::class);
}
/**
* Find the most recent Demande by query (business name)
*/
public function findMostRecentByQuery(string $query): ?Demande
{
return $this->createQueryBuilder('d')
->andWhere('d.query = :query')
->setParameter('query', $query)
->orderBy('d.createdAt', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
;
}
/**
* Find Demandes without an email
*/
public function findWithoutEmail(): array
{
return $this->createQueryBuilder('d')
->andWhere('d.email IS NULL')
->orderBy('d.createdAt', 'DESC')
->getQuery()
->getResult()
;
}
/**
* Find Demandes by status
*/
public function findByStatus(string $status): array
{
return $this->createQueryBuilder('d')
->andWhere('d.status = :status')
->setParameter('status', $status)
->orderBy('d.createdAt', 'DESC')
->getQuery()
->getResult()
;
}
/**
* Find Demandes with a Place UUID
*/
public function findWithPlaceUuid(): array
{
return $this->createQueryBuilder('d')
->andWhere('d.placeUuid IS NOT NULL')
->orderBy('d.createdAt', 'DESC')
->getQuery()
->getResult()
;
}
/**
* Find all Demandes in reverse chronological order
*/
public function findAllOrderedByCreatedAt(): array
{
return $this->createQueryBuilder('d')
->orderBy('d.createdAt', 'DESC')
->getQuery()
->getResult()
;
}
/**
* Find Places that have been contacted, ordered by last contact attempt
*/
public function findPlacesWithContactAttempt(): array
{
return $this->createQueryBuilder('d')
->andWhere('d.lastContactAttempt IS NOT NULL')
->andWhere('d.place IS NOT NULL')
->orderBy('d.lastContactAttempt', 'DESC')
->getQuery()
->getResult()
;
}
}

View file

@ -16,6 +16,42 @@ class StatsRepository extends ServiceEntityRepository
parent::__construct($registry, Stats::class);
}
/**
* Find all cities without using problematic columns
*
* @return Stats[] Returns an array of Stats objects
*/
public function findAllCitiesWithoutLabourage(): array
{
// Use native SQL to avoid ORM mapping issues with missing columns
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT id, zone, completion_percent, places_count, avec_horaires,
avec_adresse, avec_site, avec_accessibilite, avec_note,
name, population, siren, code_epci, codes_postaux,
date_created, date_modified, avec_siret, avec_name,
osm_data_date_min, osm_data_date_avg, osm_data_date_max,
budget_annuel, lat, lon
FROM stats
WHERE zone != :global_zone
';
$stmt = $conn->prepare($sql);
$resultSet = $stmt->executeQuery(['global_zone' => '00000']);
$results = $resultSet->fetchAllAssociative();
// Get existing Stats entities by ID
$statsEntities = [];
foreach ($results as $row) {
$stats = $this->find($row['id']);
if ($stats) {
$statsEntities[] = $stats;
}
}
return $statsEntities;
}
// /**
// * @return Stats[] Returns an array of Stats objects
// */