add apelido

This commit is contained in:
2025-06-02 16:47:24 -03:00
parent a3d67198af
commit 03b1f4f1d1
8 changed files with 66 additions and 11 deletions

View File

@@ -15,11 +15,21 @@ namespace OpenCand.Repository
using (var connection = new NpgsqlConnection(ConnectionString))
{
return (await connection.QueryAsync<Candidato>(@"
SELECT idcandidato, cpf, nome, datanascimento, email, sexo, estadocivil, escolaridade, ocupacao
SELECT *
CASE
WHEN lower(nome) = lower(@query) THEN 0 -- Exact match (case-insensitive)
WHEN lower(nome) LIKE lower(@query) || '%' THEN 1 -- Starts with match (case-insensitive)
WHEN lower(nome) LIKE '%' || lower(@query) THEN 2 -- Contains anywhere match (case-insensitive)
WHEN cpf = @query THEN 0 -- Exact match for CPF
WHEN cpf LIKE @query || '%' THEN 1 -- Starts with match for CPF
WHEN cpf LIKE '%' || @query THEN 2 -- Contains anywhere match for CPF
ELSE 3
END AS name_rank
FROM candidato
WHERE nome ILIKE '%' || @query || '%' OR
cpf ILIKE '%' || @query || '%' OR
email ILIKE '%' || @query || '%'
cpf ILIKE '%' || @query || '%'
ORDER BY name_rank,
length(nome) ASC
LIMIT 10;",
new { query })).AsList();
}

View File

@@ -0,0 +1,33 @@
#!/bin/bash
cd ./fotos_cand
COUNT=0
shopt -s nocaseglob
# Loop through all folders
for dir in */; do
# Change into the directory
cd "$dir" || continue
# Loop over every “.jpeg” (or “.JPEG”):
for f in *.jpeg; do
# “${f%.[jJ][pP][eE][gG]}” strips off the .jpeg/.JPEG suffix
base="${f%.[jJ][pP][eE][gG]}"
newfile="${base}.jpg"
# If theres already a .jpg with the same “base,” decide what to do:
if [ -e "$newfile" ]; then
echo "Skipping $f$newfile (target exists)"
# you could `rm "$f"` or move it to a backup folder here if you prefer
else
mv -v "$f" "$newfile"
fi
done
# Change back to the parent directory
cd ..
done
shopt -u nocaseglob
# Print a message indicating completion
echo "Normalization complete. Processed $COUNT files."