Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Run scanner
uses: aquasecurity/trivy-action@0.28.0
uses: aquasecurity/trivy-action@0.34.2
with:
scan-type: filesystem
scan-ref: .
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Date Release

on:
push:
branches:
- master

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # important to fetch all tags

- name: Generate version based on date
id: version
run: |
BASE_VERSION=$(date -u +'%Y.%-m.%-d')
echo "Base version: $BASE_VERSION"

# Fetch tags
git fetch --tags

# Find existing tags for today
MATCHING_TAGS=$(git tag -l "${BASE_VERSION}*")

if [ -z "$MATCHING_TAGS" ]; then
FINAL_VERSION=$BASE_VERSION
else
# Extract numeric suffixes
MAX_SUFFIX=$(echo "$MATCHING_TAGS" \
| grep -E "^${BASE_VERSION}-[0-9]+$" \
| sed -E "s/^${BASE_VERSION}-//" \
| sort -n \
| tail -n 1)

if [ -z "$MAX_SUFFIX" ]; then
FINAL_VERSION="${BASE_VERSION}-1"
else
NEXT=$((MAX_SUFFIX + 1))
FINAL_VERSION="${BASE_VERSION}-${NEXT}"
fi
fi

echo "Final version: $FINAL_VERSION"
echo "version=$FINAL_VERSION" >> $GITHUB_OUTPUT

- name: Create tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ Using "development" environment
Master 18385 is running
Worker 18385 started on port 3000
```

---

- adicionar busca pelo código de barras da foto
- colocar um alerta no painel quando estiver em ambiente de desenvolvimento
- issue para corrigir o DarwinCore (problema com o botão, quando clica não está funcionando)
- issue para o incremento do hcf na api ao invés do painel
- relatorio de quantidade de tombos por periodo
- relatorio tem que ter um grafico, mostrando quantos tombos foram cadastrados por periodo, somente quantitativo

- alteração na ficha tombo

nome cientifico = genero, especie, subespecie (se tiver), variedade (se tiver)
um unico tombo tem variedade e subespecie. como devemos exibir no nome cientifico?
inverter a ordem, colocar subespecie e depois variedade
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: postgres:18
image: docker.io/postgis/postgis:18-3.6
container_name: herbario_postgresql
environment:
POSTGRES_DB: $PG_DATABASE
Expand All @@ -25,7 +25,7 @@ services:

nginx:
image: nginx:1.17-alpine
container_name: berbario_nginx
container_name: herbario_nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
Expand Down
29 changes: 8 additions & 21 deletions script/database-sync/database-sync.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
#!/bin/bash

set -e
set -o pipefail

EXCLUDE_PARAMS=""
if [ -n "$SYNC_EXCLUDE_TABLES" ]; then
IFS=',' read -ra TABLES <<< "$SYNC_EXCLUDE_TABLES"
for table in "${TABLES[@]}"; do
table=$(echo "$table" | xargs)
if [ -n "$table" ]; then
EXCLUDE_PARAMS="$EXCLUDE_PARAMS --exclude-table=$table"
fi
done
echo "Excluding tables: $SYNC_EXCLUDE_TABLES"
fi
set -euo pipefail

echo "Starting synchronization process..."

PGPASSWORD="$SYNC_SOURCE_PASSWORD" pg_dump \
-h "$SYNC_SOURCE_HOST" \
-p "$SYNC_SOURCE_PORT" \
-U "$SYNC_SOURCE_USER" \
-d "$SYNC_SOURCE_DATABASE" \
--no-owner \
--no-privileges \
--clean \
--if-exists \
--no-owner \
--no-acl \
--format plain \
$EXCLUDE_PARAMS \
"$SYNC_SOURCE_DATABASE" | \
PGPASSWORD="$SYNC_DEST_PASSWORD" psql \
--format=c | \
PGPASSWORD="$SYNC_DEST_PASSWORD" pg_restore \
-h "$SYNC_DEST_HOST" \
-p "$SYNC_DEST_PORT" \
-U "$SYNC_DEST_USER" \
-d "$SYNC_DEST_DATABASE" \
--single-transaction
--clean \
--if-exists

echo "Synchronization completed successfully: ${SYNC_SOURCE_DATABASE} -> ${SYNC_DEST_DATABASE}"
5 changes: 2 additions & 3 deletions script/database-sync/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ services:
container_name: database-sync
build: .
environment:
SYNC_SOURCE_HOST: "127.0.0.1"
SYNC_SOURCE_HOST: "10.0.10.80"
SYNC_SOURCE_PORT: "5432"
SYNC_SOURCE_USER: "postgres"
SYNC_SOURCE_PASSWORD: "masterkey"
SYNC_SOURCE_DATABASE: "herbario_prod"
SYNC_DEST_HOST: "127.0.0.1"
SYNC_DEST_HOST: "10.0.10.80"
SYNC_DEST_PORT: "5432"
SYNC_DEST_USER: "postgres"
SYNC_DEST_PASSWORD: "masterkey"
SYNC_DEST_DATABASE: "herbario_dev"
SYNC_EXCLUDE_TABLES: ""
CRON_SCHEDULE: "*/2 * * * *"
TZ: "America/Sao_Paulo"
2 changes: 1 addition & 1 deletion script/database-sync/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

echo "Configuring cron job with schedule: $CRON_SCHEDULE (timezone: $TZ)"
echo "Configuring cron job with schedule: $CRON_SCHEDULE ($TZ)"

# ensure environment variables are passed to the cron job
printenv | grep -E "^SYNC_" >> /etc/environment
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/fichas-tombos-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function fichaTomboController(request, response, next) {
};

const where = {
identificacao: 1,
identificacao: true,
status: 'APROVADO',
tombo_hcf: tombo.hcf,
};
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/locais-coleta-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const buscarFasesSucessionais = (request, response, next) => {

export const cadastrarLocalColeta = async (request, response, next) => {
try {
const dados = pick(request.body, ['descricao', 'complemento', 'cidade_id', 'fase_sucessional_id']);
const dados = pick(request.body, ['descricao', 'cidade_id', 'fase_sucessional_id']);
const localColeta = await LocalColeta.create(dados);
response.status(201).json(localColeta);
} catch (error) {
Expand Down Expand Up @@ -321,7 +321,7 @@ export const buscarLocalColetaPorId = async (request, response, next) => {
export const atualizarLocalColeta = async (request, response, next) => {
try {
const { id } = request.params;
const dados = pick(request.body, ['descricao', 'complemento', 'cidade_id', 'fase_sucessional_id']);
const dados = pick(request.body, ['descricao', 'cidade_id', 'fase_sucessional_id']);
const [updated] = await LocalColeta.update(dados, {
where: { id },
});
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/pendencias-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const listagem = (request, response, next) => {
resultado: {},
};
let where = {
ativo: 1,
ativo: true,
};
let whereUsuario = {};
if (status) {
Expand Down Expand Up @@ -113,7 +113,7 @@ export const desativar = (request, response, next) => {
const callback = transaction => Promise.resolve()
.then(() => Alteracao.findOne({
where: {
ativo: 1,
ativo: true,
id,
},
transaction,
Expand All @@ -123,7 +123,7 @@ export const desativar = (request, response, next) => {
throw new BadRequestExeption(800);
}
return Alteracao.update({
ativo: 0,
ativo: false,
}, {
where: {
id,
Expand Down Expand Up @@ -1738,7 +1738,7 @@ export async function visualizar(request, response, next) {
try {
const id = request.params.pendencia_id;
const alteracao = await Alteracao.findOne({
where: { ativo: 1, id },
where: { ativo: true, id },
});

if (!alteracao) {
Expand Down Expand Up @@ -2151,14 +2151,14 @@ export function aceitarPendencia(request, response, next) {
status,
}, {
where: {
ativo: 1,
ativo: true,
id,
},
transaction,
}))
.then(() => Alteracao.findOne({
where: {
ativo: 1,
ativo: true,
id,
},
transaction,
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/relatorios-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const obtemDadosDoRelatorioDeColetaPorLocalEIntervaloDeData = async (req,
},
{
model: LocalColeta,
attributes: ['id', 'descricao', 'complemento'],
attributes: ['id', 'descricao'],
where: whereLocal,
required: true,
},
Expand Down Expand Up @@ -578,7 +578,7 @@ export const obtemDadosDoRelatorioDeLocalDeColeta = async (req, res, next) => {
},
{
model: LocalColeta,
attributes: ['id', 'descricao', 'complemento'],
attributes: ['id', 'descricao'],
where: whereLocal,
required: true,
include: {
Expand Down
14 changes: 7 additions & 7 deletions src/controllers/taxonomias-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,9 +1341,9 @@ export const editarVariedade = (request, response, next) => {

// //////////////////AUTORES//////////////////
export const cadastrarAutores = (request, response, next) => {
let { nome, iniciais } = request.body;
let { nome, observacao } = request.body;
nome = limparEspacos(nome);
iniciais = limparEspacos(iniciais);
observacao = limparEspacos(observacao);
const callback = transaction => Promise.resolve()
.then(() => Autor.findOne({
where: {
Expand All @@ -1356,7 +1356,7 @@ export const cadastrarAutores = (request, response, next) => {
throw new BadRequestExeption(513);
}
})
.then(() => Autor.create({ nome, iniciais }, transaction));
.then(() => Autor.create({ nome, observacao }, transaction));
sequelize.transaction(callback)
.then(autorCriado => {
if (!autorCriado) {
Expand Down Expand Up @@ -1409,7 +1409,7 @@ export const buscarAutores = async (request, response, next) => {
];

const result = await Autor.findAndCountAll({
attributes: ['id', 'nome', 'iniciais'],
attributes: ['id', 'nome', 'observacao'],
order,
limit: limite,
offset,
Expand Down Expand Up @@ -1476,9 +1476,9 @@ export const excluirAutores = (request, response, next) => {
};

export const editarAutores = (request, response, next) => {
let { nome, iniciais } = request.body;
let { nome, observacao } = request.body;
nome = limparEspacos(nome);
iniciais = limparEspacos(iniciais);
observacao = limparEspacos(observacao);
const autorId = parseInt(request.params.autor_id);

const callback = transaction => Promise.resolve()
Expand All @@ -1493,7 +1493,7 @@ export const editarAutores = (request, response, next) => {
throw new BadRequestExeption(517);
}
})
.then(() => Autor.update({ nome, iniciais }, {
.then(() => Autor.update({ nome, observacao }, {
where: {
id: autorId,
},
Expand Down
Loading
Loading