p.profile AS p_profile,
p.rate AS p_rate,
p.hat AS p_hat,
- GREATEST(COALESCE(s.updated, 0), COALESCE(l.updated, 0), COALESCE(t.updated, 0), COALESCE(p.updated, 0), COALESCE(MAX(sa.updated), 0), COALESCE(MAX(sau.updated), 0), COALESCE(MAX(sad.updated), 0)) AS modified,
+ GREATEST(s.created, s.updated, l.created, l.updated, t.created, t.updated, COALESCE(a.created, '1970-01-01'), COALESCE(a.updated, '1970-01-01'), COALESCE(ad.created, '1970-01-01'), COALESCE(ad.updated, '1970-01-01'), COALESCE(au.created, '1970-01-01'), COALESCE(au.updated, '1970-01-01'), COALESCE(p.created, '1970-01-01'), COALESCE(p.updated, '1970-01-01'), MAX(GREATEST(COALESCE(sa.created, '1970-01-01'), COALESCE(sa.updated, '1970-01-01'), COALESCE(sad.created, '1970-01-01'), COALESCE(sad.updated, '1970-01-01'), COALESCE(sau.created, '1970-01-01'), COALESCE(sau.updated, '1970-01-01')))) AS modified,
GROUP_CONCAT(sa.id ORDER BY sa.user_id SEPARATOR "\\n") AS sa_id,
GROUP_CONCAT(IFNULL(sa.score, 'NULL') ORDER BY sa.user_id SEPARATOR "\\n") AS sa_score,
GROUP_CONCAT(sa.created ORDER BY sa.user_id SEPARATOR "\\n") AS sa_created,
LEFT JOIN Rapsys\AirBundle\Entity\User AS au ON (au.id = a.user_id)
LEFT JOIN Rapsys\AirBundle\Entity\Snippet AS p ON (p.locale = :locale AND p.location_id = s.location_id AND p.user_id = a.user_id)
LEFT JOIN Rapsys\AirBundle\Entity\Application AS sa ON (sa.session_id = s.id)
-LEFT JOIN Rapsys\AirBundle\Entity\User AS sau ON (sau.id = sa.user_id)
LEFT JOIN Rapsys\AirBundle\Entity\Dance AS sad ON (sad.id = sa.dance_id)
+LEFT JOIN Rapsys\AirBundle\Entity\User AS sau ON (sau.id = sa.user_id)
WHERE s.id = :id
GROUP BY s.id
ORDER BY NULL
$rsm->addScalarResult('id', 'id', 'integer')
->addScalarResult('date', 'date', 'date')
->addScalarResult('begin', 'begin', 'time')
- ->addScalarResult('start', 'start', 'datetime')
+ ->addScalarResult('start', 'start', 'datetime_immutable')
->addScalarResult('length', 'length', 'time')
- ->addScalarResult('stop', 'stop', 'datetime')
+ ->addScalarResult('stop', 'stop', 'datetime_immutable')
->addScalarResult('rainfall', 'rainfall', 'float')
->addScalarResult('rainrisk', 'rainrisk', 'float')
->addScalarResult('realfeel', 'realfeel', 'float')
->addScalarResult('temperature', 'temperature', 'float')
->addScalarResult('temperaturemin', 'temperaturemin', 'float')
->addScalarResult('temperaturemax', 'temperaturemax', 'float')
- ->addScalarResult('locked', 'locked', 'datetime')
- ->addScalarResult('created', 'created', 'datetime')
- ->addScalarResult('updated', 'updated', 'datetime')
+ ->addScalarResult('locked', 'locked', 'datetime_immutable')
+ ->addScalarResult('created', 'created', 'datetime_immutable')
+ ->addScalarResult('updated', 'updated', 'datetime_immutable')
->addScalarResult('l_id', 'l_id', 'integer')
->addScalarResult('l_title', 'l_title', 'string')
->addScalarResult('l_description', 'l_description', 'string')
->addScalarResult('l_latitude', 'l_latitude', 'float')
->addScalarResult('l_longitude', 'l_longitude', 'float')
->addScalarResult('l_indoor', 'l_indoor', 'boolean')
- ->addScalarResult('l_updated', 'l_updated', 'datetime')
+ ->addScalarResult('l_updated', 'l_updated', 'datetime_immutable')
->addScalarResult('t_id', 't_id', 'integer')
->addScalarResult('t_title', 't_title', 'string')
->addScalarResult('a_id', 'a_id', 'integer')
- ->addScalarResult('a_canceled', 'a_canceled', 'datetime')
+ ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable')
->addScalarResult('ad_id', 'ad_id', 'integer')
->addScalarResult('ad_name', 'ad_name', 'string')
->addScalarResult('ad_type', 'ad_type', 'string')
->addScalarResult('p_profile', 'p_profile', 'text')
->addScalarResult('p_rate', 'p_rate', 'integer')
->addScalarResult('p_hat', 'p_hat', 'boolean')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
//XXX: is a string because of \n separator
->addScalarResult('sa_id', 'sa_id', 'string')
//XXX: is a string because of \n separator
->addIndexByScalar('id');
//Set result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('id', $id)
->getOneOrNullResult();
//XXX: check that latitude and longitude have not be swapped !!!
//XXX: latitude ~= 48.x longitude ~= 2.x
$locationIds = array_keys(
- $this->_em
+ $this->manager
->createNativeQuery($req, $rsm)
->setParameter('latitude', $latitude)
->setParameter('longitude', $longitude)
//Set location ids
$locationIds = array_keys(
- $this->_em
+ $this->manager
->createNativeQuery($req, $rsm)
->setParameter('id', $userId)
->getArrayResult()
p.hat AS p_hat,
p.rate AS p_rate,
p.short AS p_short,
- GROUP_CONCAT(sa.user_id ORDER BY sa.user_id SEPARATOR "\\n") AS sau_id,
- GROUP_CONCAT(sau.pseudonym ORDER BY sa.user_id SEPARATOR "\\n") AS sau_pseudonym,
+ GREATEST(s.created, s.updated, l.created, l.updated, t.created, t.updated, COALESCE(a.created, '1970-01-01'), COALESCE(a.updated, '1970-01-01'), COALESCE(ad.created, '1970-01-01'), COALESCE(ad.updated, '1970-01-01'), COALESCE(au.created, '1970-01-01'), COALESCE(au.updated, '1970-01-01'), COALESCE(p.created, '1970-01-01'), COALESCE(p.updated, '1970-01-01'), MAX(GREATEST(COALESCE(sa.created, '1970-01-01'), COALESCE(sa.updated, '1970-01-01'), COALESCE(sad.created, '1970-01-01'), COALESCE(sad.updated, '1970-01-01'), COALESCE(sau.created, '1970-01-01'), COALESCE(sau.updated, '1970-01-01')))) AS modified,
GROUP_CONCAT(sa.dance_id ORDER BY sa.user_id SEPARATOR "\\n") AS sad_id,
GROUP_CONCAT(sad.name ORDER BY sa.user_id SEPARATOR "\\n") AS sad_name,
GROUP_CONCAT(sad.type ORDER BY sa.user_id SEPARATOR "\\n") AS sad_type,
- GREATEST(COALESCE(s.updated, 0), COALESCE(l.updated, 0), COALESCE(p.updated, 0), COALESCE(MAX(sa.updated), 0), COALESCE(MAX(sau.updated), 0), COALESCE(MAX(sad.updated), 0)) AS modified
+ GROUP_CONCAT(sa.user_id ORDER BY sa.user_id SEPARATOR "\\n") AS sau_id,
+ GROUP_CONCAT(sau.pseudonym ORDER BY sa.user_id SEPARATOR "\\n") AS sau_pseudonym
FROM Rapsys\AirBundle\Entity\Session AS s
JOIN Rapsys\AirBundle\Entity\Location AS l ON (l.id = s.location_id)
JOIN Rapsys\AirBundle\Entity\Slot AS t ON (t.id = s.slot_id)
->addScalarResult('rainfall', 'rainfall', 'float')
->addScalarResult('realfeel', 'realfeel', 'float')
->addScalarResult('temperature', 'temperature', 'float')
- ->addScalarResult('locked', 'locked', 'datetime')
- ->addScalarResult('start', 'start', 'datetime')
- ->addScalarResult('stop', 'stop', 'datetime')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('locked', 'locked', 'datetime_immutable')
+ ->addScalarResult('start', 'start', 'datetime_immutable')
+ ->addScalarResult('stop', 'stop', 'datetime_immutable')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
->addScalarResult('t_id', 't_id', 'integer')
->addScalarResult('t_title', 't_title', 'string')
->addScalarResult('l_id', 'l_id', 'integer')
->addScalarResult('l_longitude', 'l_longitude', 'float')
->addScalarResult('l_indoor', 'l_indoor', 'boolean')
->addScalarResult('a_id', 'a_id', 'integer')
- ->addScalarResult('a_canceled', 'a_canceled', 'datetime')
+ ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable')
->addScalarResult('ad_id', 'ad_id', 'string')
->addScalarResult('ad_name', 'ad_name', 'string')
->addScalarResult('ad_type', 'ad_type', 'string')
->addScalarResult('p_rate', 'p_rate', 'integer')
->addScalarResult('p_short', 'p_short', 'string')
//XXX: is a string because of \n separator
- ->addScalarResult('sau_id', 'sau_id', 'string')
- //XXX: is a string because of \n separator
- ->addScalarResult('sau_pseudonym', 'sau_pseudonym', 'string')
- //XXX: is a string because of \n separator
->addScalarResult('sad_id', 'sad_id', 'string')
//XXX: is a string because of \n separator
->addScalarResult('sad_name', 'sad_name', 'string')
//XXX: is a string because of \n separator
->addScalarResult('sad_type', 'sad_type', 'string')
+ //XXX: is a string because of \n separator
+ ->addScalarResult('sau_id', 'sau_id', 'string')
+ //XXX: is a string because of \n separator
+ ->addScalarResult('sau_pseudonym', 'sau_pseudonym', 'string')
->addIndexByScalar('id');
//Fetch result
- $res = $this->_em
+ $res = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate());
* @param DateTime $synchronized The synchronized datetime
* @return array The session data
*/
- public function findAllByUserIdSynchronized(int $userId, \DateTime $synchronized): array {
+ public function findAllByUserIdSynchronized(int $userId, \DateTime $synchronized = new \DateTime('1970-01-01')): array {
//Set the request
$req = <<<SQL
SELECT ud.dance_id
//With user dance
if (
- $userDances = $this->_em
+ $userDances = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('uid', $userId)
->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN)
//With user subscription
if (
- $userSubscriptions = $this->_em
+ $userSubscriptions = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('uid', $userId)
->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN)
s.id,
s.date,
s.locked,
- s.updated,
+ GREATEST(s.created, s.updated, l.created, l.updated, a.created, a.updated, ad.created, ad.updated, au.created, au.updated, COALESCE(p.created, '1970-01-01'), COALESCE(p.updated, '1970-01-01')) AS modified,
ADDDATE(ADDTIME(s.date, s.begin), INTERVAL IF(s.slot_id = :afterid, 1, 0) DAY) AS start,
ADDDATE(ADDTIME(ADDTIME(s.date, s.begin), s.length), INTERVAL IF(s.slot_id = :afterid, 1, 0) DAY) AS stop,
s.location_id AS l_id,
JOIN Rapsys\AirBundle\Entity\Dance AS ad ON (ad.id = a.dance_id)
JOIN Rapsys\AirBundle\Entity\User AS au ON (au.id = a.user_id)
LEFT JOIN Rapsys\AirBundle\Entity\Snippet AS p ON (p.locale = :locale AND p.location_id = s.location_id AND p.user_id = a.user_id)
-WHERE GREATEST(s.created, s.updated, a.created, a.updated, ADDTIME(ADDTIME(s.date, s.begin), s.length)) >= :synchronized
+WHERE GREATEST(GREATEST(s.created, s.updated, l.created, l.updated, a.created, a.updated, ad.created, ad.updated, au.created, au.updated, COALESCE(p.created, '1970-01-01'), COALESCE(p.updated, '1970-01-01')), ADDDATE(ADDTIME(ADDTIME(s.date, s.begin), s.length), INTERVAL IF(s.slot_id = :afterid, 1, 0) DAY)) >= :synchronized
SQL;
//Replace bundle entity name by table name
$rsm
->addScalarResult('id', 'id', 'integer')
->addScalarResult('date', 'date', 'date')
- ->addScalarResult('locked', 'locked', 'datetime')
- ->addScalarResult('updated', 'updated', 'datetime')
- ->addScalarResult('start', 'start', 'datetime')
- ->addScalarResult('stop', 'stop', 'datetime')
+ ->addScalarResult('locked', 'locked', 'datetime_immutable')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
+ ->addScalarResult('start', 'start', 'datetime_immutable')
+ ->addScalarResult('stop', 'stop', 'datetime_immutable')
->addScalarResult('l_id', 'l_id', 'integer')
->addScalarResult('l_address', 'l_address', 'string')
->addScalarResult('l_zipcode', 'l_zipcode', 'string')
->addScalarResult('t_id', 't_id', 'integer')
->addScalarResult('t_title', 't_title', 'string')
->addScalarResult('a_id', 'a_id', 'integer')
- ->addScalarResult('a_canceled', 'a_canceled', 'datetime')
+ ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable')
->addScalarResult('ad_name', 'ad_name', 'string')
->addScalarResult('ad_type', 'ad_type', 'string')
->addScalarResult('au_id', 'au_id', 'integer')
//Return sessions
//TODO: XXX: finish here
- return $this->_em
+ return $this->manager
->createNativeQuery($req, $rsm)
->setParameter('dids', $userDances)
->setParameter('uids', $userSubscriptions)
->setParameter('synchronized', $synchronized)
- ->getArrayResult();
+ ->getResult(AbstractQuery::HYDRATE_ARRAY);
}
/**
//addScalarResult($sqlColName, $resColName, $type = 'string');
$rsm->addScalarResult('id', 'id', 'integer')
->addScalarResult('date', 'date', 'date')
- ->addScalarResult('locked', 'locked', 'datetime')
- ->addScalarResult('updated', 'updated', 'datetime')
- ->addScalarResult('start', 'start', 'datetime')
- ->addScalarResult('stop', 'stop', 'datetime')
+ ->addScalarResult('locked', 'locked', 'datetime_immutable')
+ ->addScalarResult('updated', 'updated', 'datetime_immutable')
+ ->addScalarResult('start', 'start', 'datetime_immutable')
+ ->addScalarResult('stop', 'stop', 'datetime_immutable')
->addScalarResult('l_id', 'l_id', 'integer')
->addScalarResult('l_address', 'l_address', 'string')
->addScalarResult('l_zipcode', 'l_zipcode', 'string')
->addScalarResult('t_id', 't_id', 'integer')
->addScalarResult('t_title', 't_title', 'string')
->addScalarResult('a_id', 'a_id', 'integer')
- ->addScalarResult('a_canceled', 'a_canceled', 'datetime')
+ ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable')
->addScalarResult('ad_name', 'ad_name', 'string')
->addScalarResult('ad_type', 'ad_type', 'string')
->addScalarResult('au_id', 'au_id', 'integer')
->addIndexByScalar('id');
//Fetch result
- $res = $this->_em
+ $res = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate());
->addIndexBy('s', 'id');
//Send result
- return $this->_em
+ return $this->manager
->createNativeQuery($req, $rsm)
->getResult();
}
->addIndexBy('s', 'id');
//Send result
- return $this->_em
+ return $this->manager
->createNativeQuery($req, $rsm)
->getResult();
}
->addIndexBy('s', 'id');
//Send result
- return $this->_em
+ return $this->manager
->createNativeQuery($req, $rsm)
->getResult();
}
//Get result
//XXX: setting limit in subqueries is required to prevent mariadb optimisation
- $applications = $this->_em
+ $applications = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('sid', $id)
->getResult();
//Update application updated field
//XXX: updated field is not modified for user with bad behaviour as application is not retrieved until delay is reached
- $this->_em->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]);
+ $this->manager->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]);
}
//Return best ranked application
*/
function rekey(): bool {
//Get connection
- $cnx = $this->_em->getConnection();
+ $cnx = $this->manager->getConnection();
//Set the request
$req = <<<SQL
#->addIndexByScalar('id');
//Fetch result
- $rnq = $this->_em->createNativeQuery($req, $rsm);
+ $rnq = $this->manager->createNativeQuery($req, $rsm);
//Get result set
$res = $rnq->getResult();