Commit 42b02db8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'master' into release_5.2.7

parents 6a857e26 e427bdbe
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

#############################################################################################
#        Script de lancement de l'envoi vers STEP/STAR pour un établissement.
#############################################################################################
#
# Variables d'env attendues :
#   ETAB    : Code de l'établissement à traiter (ex: "UCN"). OBLIGATOIRE.
#

usage() {
  cat << EOF
Script de lancement de l'envoi vers STEP/STAR pour un établissement.
Usage: ETAB=<etab> $0
EOF
  exit 0;
}

echo "Etablissement : $ETAB"

[[ -z "$ETAB" ]] && usage

CURR_DIR=$(cd `dirname $0` && pwd)
APP_DIR=$(cd ${CURR_DIR}/.. && pwd)

echo "Répertoire courant : $CURR_DIR"
echo "Répertoire de l'appli : $APP_DIR"

# Avorte si le script est déjà en cours d'exécution (avec les mêmes arguments)
LOCK_FILE=/run/$(basename $0)_${ETAB}.lock
echo "Lock file : $LOCK_FILE"
exec 200>$LOCK_FILE
flock -n 200
if [ $? -eq 1 ]; then
  echo "Script $(realpath $0) déjà en cours d'exécution ($LOCK_FILE). Stop !"
  exit 1
fi

echo

TAG="cron-${ETAB}-$(date +%Y%m%d_%H%M%S)"
/usr/bin/php ${APP_DIR}/public/index.php step-star:envoyer-theses --etat S --etablissement ${ETAB} --tag ${TAG} --date-soutenance-min P1M
/usr/bin/php ${APP_DIR}/public/index.php step-star:envoyer-theses --etat E --etablissement ${ETAB} --tag ${TAG}
+13 −2
Original line number Diff line number Diff line
@@ -9,7 +9,12 @@ class StrReducedTextSearchFilter extends TextSearchFilter
    protected function applyToQueryBuilderUsingWhereField(QueryBuilder $qb)
    {
        $qb
            ->andWhere(sprintf("strReduce(%s) %s strReduce(:%s)", $this->whereField, $this->getOperator(), $paramName = uniqid('p')))
            ->andWhere(sprintf(
                "strReduce(%s) %s strReduce(:%s)",
                $this->whereField,
                $this->getOperator(),
                $paramName = uniqid('p')
            ))
            ->setParameter($paramName, $this->getComparisonValue());
    }

@@ -17,7 +22,13 @@ class StrReducedTextSearchFilter extends TextSearchFilter
    {
        $alias = current($qb->getRootAliases());
        $qb
            ->andWhere(sprintf("strReduce(%s.%s) %s strReduce(:%s)", $alias, $this->getName(), $this->getOperator(), $paramName = uniqid('p')))
            ->andWhere(sprintf(
                "strReduce(%s.%s) %s strReduce(:%s)",
                $alias,
                $this->getName(),
                $this->getOperator(),
                $paramName = uniqid('p')
            ))
            ->setParameter($paramName, $this->getComparisonValue());
    }
}
+14 −3
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use Doctrine\ORM\QueryBuilder;
class TextSearchFilter extends SearchFilter
{
    protected bool $useLikeOperator = false;
    protected string $likeOperator = 'LIKE';

    /**
     * @param bool $useLikeOperator
@@ -23,9 +24,19 @@ class TextSearchFilter extends SearchFilter
        return $this;
    }

    /**
     * @param string $likeOperator
     * @return self
     */
    public function setLikeOperator(string $likeOperator): self
    {
        $this->likeOperator = $likeOperator;
        return $this;
    }

    protected function canApplyToQueryBuilder(): bool
    {
        $filterValue = $this->getValue();
        $filterValue = trim($this->getValue());

        return $filterValue !== null && strlen($filterValue) > 1;
    }
@@ -47,12 +58,12 @@ class TextSearchFilter extends SearchFilter

    protected function getOperator(): string
    {
        return $this->useLikeOperator ? 'LIKE' : '=';
        return $this->useLikeOperator ? $this->likeOperator : '=';
    }

    public function getComparisonValue(): string
    {
        $filterValue = $this->getValue();
        $filterValue = trim($this->getValue());

        return $this->useLikeOperator ? "%$filterValue%" : $filterValue;
    }
+1 −1
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ abstract class SearchService implements SearchServiceInterface
        $qb = $this->createQueryBuilder();

        foreach ($this->filters as $filter) {
            if ($filter->getValue()) {
            if ($filter->getValue() !== null) {
                $filter->applyToQueryBuilder($qb);
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ namespace Doctorant\Search;
use Application\Search\Filter\TextSearchFilter;
use Doctrine\ORM\QueryBuilder;

class DoctorantSearchFilter extends TextSearchFilter
class DoctorantSearchFilter extends TextSearchFilter // todo : hériter de StrReducedTextSearchFilter
{
    const NAME = 'doctorant';

Loading