Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhorias na qualidade e adição de testes #8

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
1653618
ignora .env
IgorAugst Nov 22, 2023
51bb280
refatora rota de placeslist
IgorAugst Nov 22, 2023
628baa6
Adiciona sql
IgorAugst Nov 23, 2023
af581ad
Adiciona alguns testes do cucumber
IgorAugst Nov 24, 2023
34354e1
Adiciona analise de código
IgorAugst Dec 3, 2023
579368d
Adiciona analise de código
IgorAugst Dec 3, 2023
af76481
Adiciona analise de código
IgorAugst Dec 3, 2023
b98868a
adiciona configuração
IgorAugst Dec 3, 2023
00de944
adiciona configuração
IgorAugst Dec 3, 2023
37f3b1b
correção trigger
IgorAugst Dec 3, 2023
594641d
correção trigger
IgorAugst Dec 3, 2023
3aa9507
Adiciona teste na placeslist
IgorAugst Dec 3, 2023
e6e276e
Remove testes da pipeline
IgorAugst Dec 3, 2023
cb543ce
corrige places
IgorAugst Dec 3, 2023
82d5173
corrige streets
IgorAugst Dec 3, 2023
951bbcc
corrige serviceaddres
IgorAugst Dec 3, 2023
ef1e77e
Merge branch 'master' into feature/testes
IgorAugst Dec 22, 2023
9eb7ba2
Merge remote-tracking branch 'origin/feature/testes' into feature/testes
IgorAugst Dec 22, 2023
03965c7
Adiciona container nos testes
IgorAugst Dec 22, 2023
02fc621
atualiza actions
IgorAugst Dec 22, 2023
5ecaa0f
atualiza nome do banco
IgorAugst Dec 22, 2023
5cd475a
atualiza workflow
IgorAugst Dec 22, 2023
cb51798
correção dockerfile
IgorAugst Dec 22, 2023
6881894
adiciona teste de users
IgorAugst Dec 22, 2023
d504c91
altera sintaxe dos testes
IgorAugst Dec 22, 2023
77c07fb
correção nos testes
IgorAugst Dec 22, 2023
9ee4dc9
altera host
IgorAugst Dec 22, 2023
3c7d107
altera timeout
IgorAugst Dec 22, 2023
cff8299
desacopla controladores
IgorAugst Dec 26, 2023
65ae566
desacopla controladores
IgorAugst Dec 26, 2023
01c6121
melhora os testes
IgorAugst Dec 26, 2023
bf00c90
desacopla streets
IgorAugst Dec 26, 2023
24c81fb
adiciona not saboya teste
IgorAugst Dec 26, 2023
0202ebb
adiciona not saboya teste
IgorAugst Dec 26, 2023
7b7a045
adiciona mais testes
IgorAugst Dec 26, 2023
778f476
muda arquivo de database
IgorAugst Dec 26, 2023
d2bc3ce
configura arquivos de testes no sonarqube
IgorAugst Dec 26, 2023
368e5e3
configura arquivos de testes no sonarqube
IgorAugst Dec 26, 2023
3323fb1
corrige conflitos
IgorAugst Dec 26, 2023
6310054
corrige conflitos
IgorAugst Dec 26, 2023
a72aed0
corrige conflitos
IgorAugst Dec 26, 2023
8e172eb
ignora testes na cobertura
IgorAugst Dec 26, 2023
92f22a2
remove arquivo inutilizado
IgorAugst Dec 26, 2023
be4c0c6
desacopla index js
IgorAugst Dec 26, 2023
d34cd2a
correção de bug
IgorAugst Dec 26, 2023
c2d85ba
remove importaçõa inutilizadas
IgorAugst Dec 26, 2023
c97c38b
altera tipos de variaveis
IgorAugst Dec 26, 2023
1f0e92a
corrige error handling
IgorAugst Dec 28, 2023
aaf1542
remove código comentado
IgorAugst Dec 28, 2023
e8e4fd7
converte variáveis
IgorAugst Dec 28, 2023
336a50c
limpa arquivo
IgorAugst Dec 28, 2023
f9a27f4
limpa arquivo lineSubstring.js
IgorAugst Dec 28, 2023
9c9d598
corrige contador nos testes de geolocalização
IgorAugst Dec 28, 2023
3c5674d
fix lineLocate.js
IgorAugst Dec 28, 2023
ba4c626
fix lineMerge.js
IgorAugst Dec 28, 2023
eb0a64f
fix searchPoint.js
IgorAugst Dec 28, 2023
1c2d3c5
fix routes
IgorAugst Dec 28, 2023
3d0dc10
fix routes
IgorAugst Dec 28, 2023
013547c
fix routes
IgorAugst Dec 28, 2023
5b482c4
teste para a mesma geolocalização
IgorAugst Dec 29, 2023
dc22ed1
desacompla saboya geolocation
IgorAugst Dec 30, 2023
17ef6be
desacompla spatial Extrapolation
IgorAugst Dec 30, 2023
bd14d70
correção de bug
IgorAugst Dec 30, 2023
10e8077
adiciona mais testes
IgorAugst Dec 30, 2023
07658cc
Merge branch 'homologacao' into feature/reduz-complexidade-igor
IgorAugst Dec 30, 2023
5f0203b
desacopla multilinestringhandler
IgorAugst Dec 30, 2023
ebeeebb
corrige bug
IgorAugst Dec 30, 2023
7db0ce4
remove else
IgorAugst Dec 30, 2023
d63fb6b
desacopla geocode
IgorAugst Dec 30, 2023
2189404
desacopla geocode
IgorAugst Dec 30, 2023
ec6d8ad
reduz complexidade na comparação de paridade
IgorAugst Dec 30, 2023
5825fd6
reduz complexidade na comparação de paridade
IgorAugst Dec 30, 2023
0937b96
reduz complexidade nos loops
IgorAugst Dec 30, 2023
1376b77
reduz complexidade nos loops
IgorAugst Dec 30, 2023
4ea50b6
reduz complexidade nos loops
IgorAugst Dec 30, 2023
a8fb0f0
adiciona dockerfile
IgorAugst Jan 2, 2024
f5591c0
Adiciona variavel para imagem docker
IgorAugst Jan 8, 2024
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATABASE_USER=postgres
DATABASE_PASS=postgres
DATABASE_HOST=localhost
DATABASE_NAME=pauliceia-teste
WEB_SERVICE_HOST=http://127.0.0.1:3000
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
# Trigger analysis when pushing to your main branches, and when creating a pull request.
push:
branches:
- '**'
pull_request:
types: [opened, synchronize, reopened]

name: Code Analysis
jobs:
npm-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Setup Docker
uses: docker-practice/actions-setup-docker@master

- name: Run Postgres container
run: docker run --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 ${{ secrets.DOCKER_IMAGE }}

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Setup .env
run: cp .env.example .env

- name: Run tests
run: npm test

- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ __pycache__

scripts/saida/clean*sample*
scripts/saida/error*sample*

.env
.idea/

.nyc_output/
coverage/
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dockerfile

FROM node:21.5.0-alpine
RUN mkdir -p /app
WORKDIR /app
COPY /package.json /package-lock.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
23 changes: 10 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
+---------------------------------------------------+
|Var
+---------------------------------------------------+*/
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var cors = require('cors');
var app = express();
const express = require('express');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const routes = require('./routes/index');
const users = require('./routes/users');
const cors = require('cors');
const app = express();
app.disable('x-powered-by');

/*
+---------------------------------------------------+
Expand All @@ -34,9 +34,6 @@ app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
//var err = new Error('Not Found');
//err.status = 404;
//next(err);

// Website you wish to allow to connect
//res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
Expand Down
83 changes: 0 additions & 83 deletions controllers/closestPoint.js

This file was deleted.

30 changes: 14 additions & 16 deletions controllers/confidenceRate.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
//p1 -> latitude, longitude, year

//Euclidian Distance
const getDistance = function(x1, y1, z1, x2, y2, z2){
return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
};
//p2 -> latitude, longitude, year

exports.confidenceRateCode = function(p1, p2, year){

//define references
var pointRef = [-46.63617,-23.54360];
var firstYear = 1860;
var lastYear = 1940;
const pointRef = [-46.63617,-23.54360];
const firstYear = 1860;
const lastYear = 1940;

//calculate distances
var distP1 = getDistance(p1[0], p1[1], year, pointRef[0], pointRef[1], year);
var distP2 = getDistance(p2[0], p2[1], year, pointRef[0], pointRef[1], year);
const distP1 = getDistance(p1[0], p1[1], year, pointRef[0], pointRef[1], year);
const distP2 = getDistance(p2[0], p2[1], year, pointRef[0], pointRef[1], year);

//calculate rate
var meanDist = (distP1+distP2)/2;
var total = getDistance(pointRef[0], pointRef[1], firstYear, pointRef[0], pointRef[1], lastYear);
var distRel = getDistance(pointRef[0], pointRef[1], firstYear, pointRef[0], pointRef[1], year);
const meanDist = (distP1+distP2)/2;
const total = getDistance(pointRef[0], pointRef[1], firstYear, pointRef[0], pointRef[1], lastYear);
const distRel = getDistance(pointRef[0], pointRef[1], firstYear, pointRef[0], pointRef[1], year);

//coenficent
var confidenceRate = (distRel+meanDist)/total; // (((distRel+meanDist)/total)-0.9)*10;

//return the rate
return confidenceRate
return (distRel + meanDist) / total
}

exports.confidenceRateLocate = function(year){
Expand All @@ -31,9 +34,4 @@ exports.confidenceRateLocate = function(year){

}

//Euclidian Distance
var getDistance = function(x1, y1, z1, x2, y2, z2){
return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
}


Loading