commit
6f24d7d5bf
4
pom.xml
4
pom.xml
@ -43,10 +43,6 @@
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-hibernate-reactive-panache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-reactive-mysql-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-reactive-pg-client</artifactId>
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package fr.titionfire.ffsaf.data;
|
||||
|
||||
import org.hibernate.boot.model.FunctionContributions;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.query.sqm.produce.function.FunctionParameterType;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.BasicTypeRegistry;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
public class CustomPostgreSQLDialect extends PostgreSQLDialect {
|
||||
private static final Logger LOGGER = Logger.getLogger(PostgreSQLDialect.class);
|
||||
|
||||
public CustomPostgreSQLDialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeFunctionRegistry(FunctionContributions functionContributions) {
|
||||
super.initializeFunctionRegistry(functionContributions);
|
||||
|
||||
LOGGER.info("Initializing custom function registry");
|
||||
|
||||
SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
|
||||
TypeConfiguration typeConfiguration = functionContributions.getTypeConfiguration();
|
||||
BasicTypeRegistry basicTypeRegistry = typeConfiguration.getBasicTypeRegistry();
|
||||
BasicType<String> stringType = basicTypeRegistry.resolve(StandardBasicTypes.STRING);
|
||||
|
||||
functionRegistry.namedDescriptorBuilder("unaccent").setInvariantType(stringType).setExactArgumentCount(1)
|
||||
.setParameterTypes(new FunctionParameterType[]{FunctionParameterType.STRING}).register();
|
||||
|
||||
}
|
||||
}
|
||||
@ -252,7 +252,7 @@ public class CompetitionService {
|
||||
} else {
|
||||
if (fname == null || lname == null)
|
||||
return Uni.createFrom().failure(new DBadRequestException("Nom et prénom requis"));
|
||||
return combRepository.find("LOWER(lname) LIKE LOWER(?1) AND LOWER(fname) LIKE LOWER(?2)", lname,
|
||||
return combRepository.find("unaccent(lname) ILIKE unaccent(?1) AND unaccent(fname) ILIKE unaccent(?2)", lname,
|
||||
fname).firstResult()
|
||||
.invoke(Unchecked.consumer(combModel -> {
|
||||
if (combModel == null)
|
||||
|
||||
@ -69,7 +69,8 @@ public class MembreService {
|
||||
|
||||
public SimpleCombModel find(int licence, String np) throws Throwable {
|
||||
return VertxContextSupport.subscribeAndAwait(() -> Panache.withTransaction(() ->
|
||||
repository.find("licence = ?1 AND (LOWER(lname) LIKE LOWER(?2) OR LOWER(fname) LIKE LOWER(?2))",
|
||||
repository.find(
|
||||
"licence = ?1 AND (unaccent(lname) ILIKE unaccent(?2) OR unaccent(fname) ILIKE unaccent(?2))",
|
||||
licence, np).firstResult().map(SimpleCombModel::fromModel)));
|
||||
}
|
||||
|
||||
@ -78,19 +79,22 @@ public class MembreService {
|
||||
() -> Panache.withTransaction(() -> repository.findById(id).map(SimpleCombModel::fromModel)));
|
||||
}
|
||||
|
||||
final static String FIND_NAME_REQUEST = "unaccent(fname) ILIKE unaccent(?1) OR unaccent(lname) ILIKE unaccent(?1) " +
|
||||
"OR unaccent(fname || ' ' || lname) ILIKE unaccent(?1) OR unaccent(lname || ' ' || fname) ILIKE unaccent(?1)";
|
||||
|
||||
public Uni<PageResult<SimpleMembre>> searchAdmin(int limit, int page, String search, String club) {
|
||||
if (search == null)
|
||||
search = "";
|
||||
search = search + "%";
|
||||
search = "%" + search.replaceAll(" ", "% %") + "%";
|
||||
|
||||
PanacheQuery<MembreModel> query;
|
||||
|
||||
if (club == null || club.isBlank())
|
||||
query = repository.find("(LOWER(lname) LIKE LOWER(?1) OR LOWER(fname) LIKE LOWER(?1))",
|
||||
Sort.ascending("fname", "lname"), search).page(Page.ofSize(limit));
|
||||
else
|
||||
if (club == null || club.isBlank()) {
|
||||
query = repository.find(FIND_NAME_REQUEST, Sort.ascending("fname", "lname"), search)
|
||||
.page(Page.ofSize(limit));
|
||||
} else
|
||||
query = repository.find(
|
||||
"LOWER(club.name) LIKE LOWER(?2) AND (LOWER(lname) LIKE LOWER(?1) OR LOWER(fname) LIKE LOWER(?1))",
|
||||
"LOWER(club.name) LIKE LOWER(?2) AND (" + FIND_NAME_REQUEST + ")",
|
||||
Sort.ascending("fname", "lname"), search, club + "%").page(Page.ofSize(limit));
|
||||
return getPageResult(query, limit, page);
|
||||
}
|
||||
@ -98,12 +102,13 @@ public class MembreService {
|
||||
public Uni<PageResult<SimpleMembre>> search(int limit, int page, String search, String subject) {
|
||||
if (search == null)
|
||||
search = "";
|
||||
search = search + "%";
|
||||
search = "%" + search.replaceAll(" ", "% %") + "%";
|
||||
|
||||
String finalSearch = search;
|
||||
return repository.find("userId = ?1", subject).firstResult()
|
||||
.chain(membreModel -> {
|
||||
PanacheQuery<MembreModel> query = repository.find(
|
||||
"club = ?1 AND (LOWER(lname) LIKE LOWER(?2) OR LOWER(fname) LIKE LOWER(?2))",
|
||||
"club = ?1 AND (" + FIND_NAME_REQUEST + ")",
|
||||
Sort.ascending("fname", "lname"), membreModel.getClub(), finalSearch)
|
||||
.page(Page.ofSize(limit));
|
||||
return getPageResult(query, limit, page);
|
||||
|
||||
@ -48,25 +48,25 @@ public class Utils {
|
||||
int birthYear = toCalendar(birth_date).get(Calendar.YEAR);
|
||||
|
||||
int diff = currentSaison - birthYear;
|
||||
if (diff < 6) {
|
||||
if (diff < 7) {
|
||||
return Categorie.SUPER_MINI;
|
||||
} else if (diff < 8) {
|
||||
} else if (diff < 9) {
|
||||
return Categorie.MINI_POUSSIN;
|
||||
} else if (diff < 10) {
|
||||
} else if (diff < 11) {
|
||||
return Categorie.POUSSIN;
|
||||
} else if (diff < 12) {
|
||||
} else if (diff < 13) {
|
||||
return Categorie.BENJAMIN;
|
||||
} else if (diff < 14) {
|
||||
} else if (diff < 15) {
|
||||
return Categorie.MINIME;
|
||||
} else if (diff < 16) {
|
||||
} else if (diff < 17) {
|
||||
return Categorie.CADET;
|
||||
} else if (diff < 18) {
|
||||
} else if (diff < 19) {
|
||||
return Categorie.JUNIOR;
|
||||
} else if (diff < 24) {
|
||||
} else if (diff < 25) {
|
||||
return Categorie.SENIOR1;
|
||||
} else if (diff < 34) {
|
||||
} else if (diff < 35) {
|
||||
return Categorie.SENIOR2;
|
||||
} else if (diff < 44) {
|
||||
} else if (diff < 45) {
|
||||
return Categorie.VETERAN1;
|
||||
} else {
|
||||
return Categorie.VETERAN2;
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
# DEV
|
||||
%dev.quarkus.datasource.db-kind=mysql
|
||||
%dev.quarkus.datasource.reactive.url=mysql://${database.hostname}:${database.port}/${database.database}?charset=utf8mb4
|
||||
|
||||
# DB
|
||||
quarkus.datasource.db-kind=postgresql
|
||||
quarkus.datasource.username=${database.user}
|
||||
@ -11,6 +7,8 @@ quarkus.datasource.reactive.url=postgresql://${database.hostname}:${database.por
|
||||
quarkus.hibernate-orm.database.generation=update
|
||||
quarkus.hibernate-orm.physical-naming-strategy=fr.titionfire.ffsaf.data.SafcaNamingStrategy
|
||||
|
||||
quarkus.hibernate-orm.dialect=fr.titionfire.ffsaf.data.CustomPostgreSQLDialect
|
||||
|
||||
quarkus.http.cors=true
|
||||
quarkus.quartz.start-mode=forced
|
||||
|
||||
|
||||
@ -17,25 +17,25 @@ export function getCategoryFormBirthDate(birth_date, currentDate = new Date()) {
|
||||
const birthYear = birth_date.getFullYear()
|
||||
|
||||
const diff = currentSaison - birthYear;
|
||||
if (diff < 6) {
|
||||
if (diff < 7) {
|
||||
return "SUPER_MINI";
|
||||
} else if (diff < 8) {
|
||||
} else if (diff < 9) {
|
||||
return "MINI_POUSSIN";
|
||||
} else if (diff < 10) {
|
||||
} else if (diff < 11) {
|
||||
return "POUSSIN";
|
||||
} else if (diff < 12) {
|
||||
} else if (diff < 13) {
|
||||
return "BENJAMIN";
|
||||
} else if (diff < 14) {
|
||||
} else if (diff < 15) {
|
||||
return "MINIME";
|
||||
} else if (diff < 16) {
|
||||
} else if (diff < 17) {
|
||||
return "CADET";
|
||||
} else if (diff < 18) {
|
||||
} else if (diff < 19) {
|
||||
return "JUNIOR";
|
||||
} else if (diff < 24) {
|
||||
} else if (diff < 25) {
|
||||
return "SENIOR1";
|
||||
} else if (diff < 34) {
|
||||
} else if (diff < 35) {
|
||||
return "SENIOR2";
|
||||
} else if (diff < 44) {
|
||||
} else if (diff < 45) {
|
||||
return "VETERAN1";
|
||||
} else {
|
||||
return "VETERAN2";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user