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

Manual de fuga #16

Open
wants to merge 156 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
987f0fc
PR pra filtrar 00
renatocron May 12, 2023
dc98f78
Fix pra só considerar quando ambos lat/long for perto do zero ao mesm…
renatocron May 12, 2023
c2b64a2
Retorno de texto em cliente_list_events_audio
renatocron May 18, 2023
df533cd
PR pra filtrar 00
renatocron May 12, 2023
cd1eec7
Fix pra só considerar quando ambos lat/long for perto do zero ao mesm…
renatocron May 12, 2023
d416096
Fix space
renatocron May 18, 2023
2af23f9
Merge branch 'master' into homol
renatocron May 20, 2023
16653f3
WIP
renatocron Mar 31, 2023
f6abc46
Fix teste t/api/058-anon-quiz.t (tirar o floor da query pra resolver …
renatocron Apr 5, 2023
8a157dc
Fix mais um teste
renatocron Apr 5, 2023
50c88fc
Marcar, Desmarcar e remover tarefas
renatocron Apr 6, 2023
705f674
Adicionando endpoint para Nova tarefa
renatocron Apr 6, 2023
b256d1c
tidy
renatocron May 3, 2023
b7740d9
Endpoints para atualizar tarefa
renatocron May 20, 2023
4890205
modulo mf
renatocron May 20, 2023
550329b
Fix carregamento do modulo mf
renatocron May 20, 2023
463680f
Add: Você ainda não tem nenhum áudio gravado.
renatocron May 29, 2023
dca2f89
PR pra filtrar 00
renatocron May 12, 2023
9a51345
Fix pra só considerar quando ambos lat/long for perto do zero ao mesm…
renatocron May 12, 2023
6f06592
Feat/task padrao atualizada (#8)
renatocron Jun 3, 2023
fcd2a4f
Fix syntax err
renatocron Jun 3, 2023
22d7404
Feat/task padrao (#10)
renatocron Jun 30, 2023
5ce4060
Fix 0028-mf-info.sql
renatocron Jun 30, 2023
7ef7ffe
Update autocontinue nao existe
renatocron Jun 30, 2023
03db579
More log
renatocron Jun 30, 2023
99fb9e3
More logs
renatocron Jun 30, 2023
ea4eb6a
Change to get_column
renatocron Jun 30, 2023
61488d1
Rm cover (should not exists at repo)
renatocron Jun 30, 2023
f6b6e59
Confess if user.id not found
renatocron Jun 30, 2023
66c5920
Fix get_columns on user
renatocron Jun 30, 2023
3a4d13a
Fix load_quiz_session on get /me/tarefas
renatocron Jun 30, 2023
d878bb9
Add tests / fix get /me/tarefas during quiz
renatocron Jun 30, 2023
f88a1df
Fix force end
renatocron Jun 30, 2023
05b8943
Add lorem
renatocron Jun 30, 2023
14cdeb1
Fix GET mf_assistant
renatocron Jun 30, 2023
cfb819c
cliente_mf_add_tag_by_code e fix migration
renatocron Jul 4, 2023
f88bb2a
Pular msg vazias pro frontend (mas marcar tarefas/tags)
renatocron Jul 4, 2023
a041826
Add _json on MC questions to easy detect the responses
renatocron Jul 7, 2023
2c00963
Update parser.ts para montar o multiplechoice
renatocron Jul 7, 2023
af2d17a
Fix Anon quiz, mas o teste ainda ta quebrado
renatocron Jul 7, 2023
d3f1830
Fix display do resultados do CEP
renatocron Jul 7, 2023
d1e9a66
Não existe cep_results no app, logo, não faz sentido o teste no _skip…
renatocron Jul 7, 2023
8d7d9ef
Add endpoint/column pra qtde_login_offline
renatocron Jul 8, 2023
5b5025c
Fix encoding do 🗑
renatocron Jul 8, 2023
ea8f1a5
Add tag_user to parse.ts
renatocron Jul 8, 2023
597bfcd
Patch https://ws.iwebservice.digital/CPF/
renatocron Jul 17, 2023
43d5317
Atualizando .XLSX, .SQL e debug quando o render do relevance é undef
renatocron Jul 18, 2023
c5d2484
Mais logs
renatocron Jul 18, 2023
2653f45
Skip empty messages on any_has_relevance
renatocron Jul 18, 2023
922e27c
Adicionando PQ
renatocron Jul 18, 2023
6584af6
Atualizando agrupador da tarefas
renatocron Jul 18, 2023
d860152
Fix P4ac
renatocron Jul 26, 2023
0513f6d
Adicionar linkfy (e .prettierrc)
renatocron Jul 28, 2023
910d5b3
Fix TS warnings
renatocron Jul 28, 2023
471e6c4
Caso tenha links nas respostas
renatocron Jul 28, 2023
c3b9f28
Revisao parser (chars nao visiveis)
renatocron Jul 28, 2023
ae26265
Colocar exception se um dia faltar 2 opcoes pro yesno, 3 pro yesnomaybe
renatocron Aug 1, 2023
6877723
Fix is_json_member when array is not initialized yet
renatocron Aug 1, 2023
16f46fa
Adicionar suporte do PQ como pergunta (e não como opcoes)
renatocron Aug 1, 2023
23df8eb
Tidy
renatocron Aug 1, 2023
5642c12
Correção no local de insert do PQ (um por pergunta e nao por cada res…
renatocron Aug 1, 2023
406323a
Add tests to cover json_array_to_string/is_json_member
renatocron Aug 4, 2023
e203014
new version parser
renatocron Aug 11, 2023
559d083
Usando o código da resposta, no lugar do texto, por causa dos textos …
renatocron Aug 11, 2023
4291cd0
Add debug do quiz
renatocron Aug 14, 2023
df3d95c
$q is not public
renatocron Aug 14, 2023
472b9f6
use _code
renatocron Aug 14, 2023
9c1d272
nova versao do quiz
renatocron Aug 18, 2023
77f6a2e
atualizar texto descricao do MF
renatocron Aug 18, 2023
b0da28e
Parser: Adicionando pergunta sim/nao para limpeza de tarefas e tag (S…
renatocron Sep 1, 2023
718c40b
Add cliente_mf_clear_tasks via tags
renatocron Sep 15, 2023
091be66
Add column ja_completou_mf
renatocron Sep 15, 2023
1d2d6ad
Adicionando versão em Batch para endpoint do sync
renatocron Oct 10, 2023
b7332de
Removendo DDP
renatocron Oct 10, 2023
e91be03
Add campo consultado_em
renatocron Oct 20, 2023
870fbf2
Fix atualizado_em >= no lugar de >
renatocron Oct 20, 2023
a6851e8
Add ViaCep
renatocron Oct 28, 2023
f8c7da9
Atualizando textos
renatocron Oct 31, 2023
a491964
Update docker to FROM phusion/baseimage:focal-1.2.0
renatocron Dec 1, 2023
1cda9a4
Adicionando logs em cliente_sync_lista_tarefas
renatocron Jan 4, 2024
8c4d9f3
Resolvendo warning na linha 260 em lib/Penhas/Controller.pm
renatocron Jan 4, 2024
c9c995a
Patch na tarefa especial
renatocron Jan 4, 2024
ef93169
Atualizando parser do MF para detectar texto do checkbox_contato
renatocron Jan 4, 2024
1a12cfb
Adicionando NAO_LIMPA_MF
renatocron Feb 1, 2024
8eba29e
Update index
renatocron Feb 1, 2024
4a8397c
Update textos
renatocron Feb 1, 2024
22f1e91
Adicionando regra para limpar determinados codigos ao entrar no bloco
renatocron Feb 1, 2024
d93adce
Add codigo_tarefa
renatocron Feb 1, 2024
5792166
Add sql code for tag NAO_LIMPA_MF
renatocron Feb 1, 2024
e74abb1
Adicionando render_botao_endereco para verficar se o app já quebra, rs
renatocron Feb 1, 2024
d62082a
Perl is hard
renatocron Feb 1, 2024
e07afb0
Adicionando codigo para iniciar o MF_REDO_ADDR_QUESTIONNAIRE_ID
renatocron Feb 1, 2024
e8265b4
Registrando process_redo_addr_mf_assistant
renatocron Feb 1, 2024
dc58d8c
Update rota para render_botao_endereco
renatocron Feb 11, 2024
3814b13
Simplificando regra de carregamento do quiz
renatocron Feb 13, 2024
c7d75f3
Tratamento para always_new_session
renatocron Feb 13, 2024
8b61656
Filtro por $opts{session_id} na busca da resposta
renatocron Feb 13, 2024
e3fd13d
auto_change_questionnaire não é iterativo
renatocron Feb 15, 2024
ed45e5f
Add more lo
renatocron Feb 15, 2024
199cbc3
Print stash before mod
renatocron Feb 15, 2024
519ad68
Set auto_change_questionnaire as input again
renatocron Feb 15, 2024
5d64c18
Fix bug de 4 anos: mover msgs sem relevancia do current pro pending a…
renatocron Feb 15, 2024
6e2a3bf
Movendo para pending antes do add_more_questions
renatocron Feb 15, 2024
456ec3c
Update quiz
renatocron Feb 15, 2024
8865f6c
Atualizando quiz
renatocron Feb 15, 2024
c083084
Atualizando label do botão
renatocron Feb 16, 2024
b998f32
Atualizar botao final para Concluir tambem
renatocron Feb 16, 2024
17dd74c
Update texto lib/Penhas/Helpers/Cliente.pm
renatocron Feb 21, 2024
0fd39c5
Movimentando campo_livre para tabela mf_cliente_tarefa
renatocron Mar 1, 2024
a190efe
Mudando tarefa de contato
renatocron Mar 1, 2024
793ee8d
Update quiz
renatocron Mar 1, 2024
ca9ea6a
Fix revisar
renatocron Mar 1, 2024
6fa61ac
update quiz
renatocron Mar 5, 2024
5cef628
Fix _currently_has_relevance para items recem adicionados no loop
renatocron Mar 6, 2024
5b5f127
Manter prev_msgs ao encaminhar questionario
renatocron Mar 6, 2024
32519b2
Manter prev_msgs tbm na pergunta do tipo change_questionnaire
renatocron Mar 6, 2024
fb7626b
Fix mf_tag
renatocron Mar 7, 2024
4460cb3
Add ENABLE_MANUAL_FUGA_IDS
renatocron Mar 7, 2024
8be63fb
Better use of ENABLE_MANUAL_FUGA_IDS
renatocron Mar 7, 2024
e817562
Fix _build_access_modules
renatocron Mar 7, 2024
b22b6a1
Adicionar mf_control_id no processo de refazer o endereço
renatocron Mar 7, 2024
3de2327
Update quiz
renatocron Mar 7, 2024
5516be9
Fix created_on on ClienteTag
renatocron Mar 7, 2024
9c793be
Add log of $mf_sc->status()
renatocron Mar 8, 2024
a5e9dda
Chamando discard_changes no ensure_cliente_mf_session_control_exists
renatocron Mar 8, 2024
07a8974
Add texto ataulização pro legacy
renatocron Mar 21, 2024
808608c
Fix of created_at legacy tweet
renatocron Mar 21, 2024
6e53041
Change to unshfit
renatocron Mar 21, 2024
e47f18a
Msg de boas vindas automatica
renatocron Mar 21, 2024
dfbbb55
Ajuste texto legacy
renatocron Mar 23, 2024
0a4161c
link para loja
renatocron Mar 23, 2024
c6a2f56
Titulo: atualização está disponível
renatocron Mar 23, 2024
a80c608
Criando versão maybe_linkfy
renatocron Apr 5, 2024
a5428d5
Fix maybe_linkfy para usar o $penhas_avatar que é do tweet e não vari…
renatocron Apr 5, 2024
e69de19
Fix tag deve entrar sempre ao passar por um $item->{type} eq tag_user…
renatocron Apr 25, 2024
dd75e67
Fix $tag que está sumindo da $item em algum momento
renatocron Apr 25, 2024
058a9c3
add sql of metabase
renatocron Apr 26, 2024
c0ba4dd
Add workflow to build and publish image
renatocron May 10, 2024
86993fe
Patch docker/Dockerfile to copy api code to /src
renatocron May 10, 2024
afbb60d
Fix Makefile.PL copy (no need more local copy)
renatocron May 10, 2024
325e81a
Finish adjust for docker/
renatocron May 10, 2024
b0ee59c
Add RUN chown 1000:1000 /src/ -R to end of Dockerfile
renatocron May 10, 2024
f89dc0d
Add api/integracoes.md
renatocron May 18, 2024
1d7fec3
Add favicon
renatocron May 24, 2024
4029d29
Fix lib/Penhas/CEP/ViaCep.pm
renatocron May 24, 2024
14f733e
Add pagina de exclusao
renatocron May 24, 2024
324b356
fix(SignUp.pm, CepUpdater.pm): remove suporte ao backend Correios e P…
renatocron Jul 12, 2024
52ce154
Update quiz for new tags
renatocron Aug 9, 2024
5ad72c2
feat(metricas-de-uso-do-manual-de-fuga.sql): expande as tags no view …
renatocron Aug 9, 2024
d2f3ad7
Add DB_SSL__REJECT_UNAUTHORIZED=false
renatocron Aug 20, 2024
559a6ec
feat(deploy_db): adiciona função e trigger para prevenir duplicatas e…
renatocron Sep 19, 2024
58880c8
feat(Maintenance.pm): adiciona limpeza de sessões de cliente com mais…
renatocron Sep 19, 2024
f0a7a87
fix(Maintenance.pm): altera retorno de renderização JSON para valor b…
renatocron Sep 19, 2024
2857077
Update docker-compose
renatocron Oct 11, 2024
3657bcb
feat(ClienteTag.pm): adiciona restrição de unicidade para cliente_id …
renatocron Oct 11, 2024
3c29538
Atualizando arquivo de sqitch
renatocron Oct 11, 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
40 changes: 40 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Create and publish the Docker image

on:
push:
branches: ['homol']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precisamos mudar isso aqui para permitir tanto homol quanto master


env:
IMAGE_NAME: ghcr.io/institutoazmina/penhas-backend

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./api/
file: ./api/docker/Dockerfile
push: true
tags: ${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ github.sha }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acho que vamos precisar de um step intermediário para definir a lista de tags, separando o que é production e o que é homol.

cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest
cache-to: type=inline
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
docker-compose-local.yaml

### VisualStudioCode ###
.vstags
Expand All @@ -8,3 +9,4 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*xlsx#
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tabWidth": 4,
"useTabs": false,
"endOfLine": "lf",
"trailingComma": "es5",
"insertPragma": false,
"printWidth": 120,
"bracketSpacing": true,
"arrowParens": "always",
"singleQuote": true,
"quoteProps": "preserve",
"semi": true
}
2 changes: 0 additions & 2 deletions api/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ my %WriteMakefileArgs = (
"Crypt::Passphrase::Argon2" => 0,
"Crypt::Rijndael" => "1.16",
"DBD::Pg" => 0,
"DBD::mysql" => 0,
"DBIx::Class::Core" => 0,
"DBIx::Class::InflateColumn::Serializer" => 0,
"DBIx::Class::PassphraseColumn" => 0,
Expand Down Expand Up @@ -172,7 +171,6 @@ my %FallbackPrereqs = (
"Crypt::Passphrase::Argon2" => 0,
"Crypt::Rijndael" => "1.16",
"DBD::Pg" => 0,
"DBD::mysql" => 0,
"DBIx::Class::Core" => 0,
"DBIx::Class::InflateColumn::Serializer" => 0,
"DBIx::Class::PassphraseColumn" => 0,
Expand Down
2 changes: 2 additions & 0 deletions api/cover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cpanm -n Devel::Cover
HARNESS_PERL_SWITCHES=-MDevel::Cover prove -lvr t/
50 changes: 50 additions & 0 deletions api/deploy_db/deploy/0027-tarefa-padrao.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- Deploy penhas:0027-tarefa-padrao to pg
-- requires: 0026-block-users

BEGIN;


-- alter table mf_tarefa drop column campo_livre_1, drop column campo_livre_2, drop column campo_livre_3;
-- alter table mf_tarefa add column campo_livre json;

create table mf_tarefa (
id serial primary key not null,

titulo varchar not null,
descricao varchar not null,

tipo varchar not null default 'checkbox',
codigo varchar,

campo_livre json,

agrupador varchar(120) not null default 'Outros',

criado_em timestamp without time zone not null default now(),
-- se é editável ou não pela usuária
eh_customizada boolean not null default false
);

create table mf_cliente_tarefa (
id serial primary key not null,

mf_tarefa_id int not null references mf_tarefa(id),
cliente_id bigint not null references clientes(id),

checkbox_feito boolean not null default false,

checkbox_feito_checked_first_updated_at timestamp without time zone,
checkbox_feito_checked_last_updated_at timestamp without time zone,

checkbox_feito_unchecked_first_updated_at timestamp without time zone,
checkbox_feito_unchecked_last_updated_at timestamp without time zone,

criado_em timestamp without time zone not null default now(),
removido_em timestamp without time zone,

last_from_questionnaire int references questionnaires(id),

atualizado_em timestamp without time zone not null default now()
);

COMMIT;
74 changes: 74 additions & 0 deletions api/deploy_db/deploy/0028-mf-info.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
-- Deploy penhas:0028-mf-info to pg
-- requires: 0027-tarefa-padrao

BEGIN;

create unique index ix_mf_codigo_tarefa on mf_tarefa (codigo) where codigo != '';

alter table quiz_config alter column intro set default '[]',
alter column yesnogroup set default '[]';

-- guarda a ordem preferencial dos blocos de questionarios do manual de fuga
create table mf_questionnaire_order (
id serial not null primary key,

sort int not null default 0,

outstanding_order boolean not null default false,

is_last boolean not null default false,

published character varying(20) default 'testing',

questionnaire_id int not null references questionnaires(id)
);

-- statuses:
-- onboarding
-- inProgress
-- completed
create table cliente_mf_session_control (
cliente_id int not null references clientes(id) ON DELETE CASCADE primary key,

status varchar not null default 'onboarding',

current_clientes_quiz_session int references clientes_quiz_session(id),
completed_questionnaires_id int[] not null default '{}'::int[],

started_at timestamp without time zone not null default now(),
completed_at timestamp without time zone
);

-- novos tipo na quiz_config:
-- next_mf_questionnaire
-- next_mf_questionnaire_outstanding
-- auto_change_questionnaire
-- yesnomaybe
-- multiplechoice
-- tag_user
-- text << já existia, mas não tem no app

alter table quiz_config add column change_to_questionnaire_id int references questionnaires(id) default null;
alter table quiz_config add column tarefas json not null default '[]';

-- not really mf, mas já tem uma table "tags" lá pro feed/noticias
create table mf_tag (
id serial not null primary key,
code varchar not null unique,
description varchar,
created_on timestamp without time zone not null default now()
);

create table cliente_tag (
id serial not null primary key,

cliente_id int not null references clientes(id) ON DELETE CASCADE,
mf_tag_id int not null references mf_tag(id) ON DELETE CASCADE ,

created_on timestamp without time zone not null default now()
);

alter table quiz_config add column tag json not null default '[]';
alter table quiz_config alter tag set not null;

COMMIT;
8 changes: 8 additions & 0 deletions api/deploy_db/deploy/0029-cliente_offline.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Deploy penhas:0029-cliente_offline to pg
-- requires: 0028-mf-info

BEGIN;

alter table clientes add column qtde_login_offline int not null default 0;

COMMIT;
8 changes: 8 additions & 0 deletions api/deploy_db/deploy/0030-ja_completou_mf.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Deploy penhas:0030-ja_completou_mf to pg
-- requires: 0029-cliente_offline

BEGIN;

alter table clientes add column ja_completou_mf boolean default false;

COMMIT;
12 changes: 12 additions & 0 deletions api/deploy_db/deploy/0031-mf_block_clear.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Deploy penhas:0031-mf_block_clear to pg
-- requires: 0030-ja_completou_mf

BEGIN;

create table mf_questionnaire_remove_tarefa (
id serial not null primary key,
questionnaire_id int not null references questionnaires(id),
codigo_tarefa varchar not null
);

COMMIT;
10 changes: 10 additions & 0 deletions api/deploy_db/deploy/0032-fix-campo_livre.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Deploy penhas:0032-fix-campo_livre to pg
-- requires: 0031-mf_block_clear

BEGIN;

alter table mf_tarefa drop column campo_livre;
alter table mf_cliente_tarefa add column campo_livre json;


COMMIT;
6 changes: 6 additions & 0 deletions api/deploy_db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@
0024-sugestao_ponto_apoio_2 [0023-ponto_apoio_keywords_log] 2022-07-16T03:38:26Z renato,,, <renato@renato-MS-7A34> # nova
0025-pa-sug-form [0024-sugestao_ponto_apoio_2] 2022-08-04T17:03:02Z renato,,, <renato@renato-MS-7A34> # form
0026-block-users [0025-pa-sug-form] 2023-03-04T15:05:16Z renato,,, <renato@renato-MS-7A34> # block users and report users
0027-tarefa-padrao [0026-block-users] 2023-03-24T00:14:44Z renato,,, <renato@renato-MS-7A34> # tarefa padrao e tarefa para uma usuaria
0028-mf-info [0027-tarefa-padrao] 2023-05-25T21:13:39Z renato,,, <renato@renato-Inspiron-7580> # mf cliente
0029-cliente_offline [0028-mf-info] 2023-07-08T12:40:44Z renato,,, <renato@renato-MS-7A34> # cliente-offline
0030-ja_completou_mf [0029-cliente_offline] 2023-09-15T13:05:31Z renato,,, <renato@renato-MS-7A34> # ja_completou_mf
0031-mf_block_clear [0030-ja_completou_mf] 2024-02-01T12:16:07Z renato,,, <renato@renato-MS-7A34> # clear tasks when block start
0032-fix-campo_livre [0031-mf_block_clear] 2024-03-01T01:37:39Z renato,,, <renato@renato-MS-7A34> # Fix campo_livre movendo da tarefa pro cliente-tarefa
1 change: 0 additions & 1 deletion api/dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Net::DNS::Native = 0
App::Sqitch = 0
IO::Socket::SSL = 0
DBD::Pg = 0
DBD::mysql = 0
DBIx::Class::TimeStamp = 0
DBIx::Class::PassphraseColumn = 0
DBIx::Class::InflateColumn::Serializer = 0
Expand Down
18 changes: 11 additions & 7 deletions api/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM phusion/baseimage:focal-1.0.0
FROM phusion/baseimage:focal-1.2.0
CMD ["/sbin/my_init"]

RUN apt-get update && apt-get install -y \
Expand All @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \
RUN useradd -ms /bin/bash app;

USER app
ADD install-perlbrew.sh /tmp/install-perlbrew.sh
ADD docker/install-perlbrew.sh /tmp/install-perlbrew.sh
RUN /tmp/install-perlbrew.sh

USER root
Expand All @@ -23,7 +23,7 @@ RUN apt-get update && apt-get install -y \

USER app

ADD install-cpan-modules.sh /tmp/install-cpan-modules.sh
ADD docker/install-cpan-modules.sh /tmp/install-cpan-modules.sh
RUN /tmp/install-cpan-modules.sh

USER root
Expand All @@ -33,13 +33,17 @@ RUN apt-get update && apt-get install -y \

USER app

ADD Makefile_local.PL /tmp/Makefile.PL
ADD install-cpan-extra-modules.sh /tmp/install-cpan-extra-modules.sh
ADD ./Makefile.PL /tmp/Makefile.PL
ADD docker/install-cpan-extra-modules.sh /tmp/install-cpan-extra-modules.sh
RUN /tmp/install-cpan-extra-modules.sh

USER root
RUN mkdir /etc/service/api
COPY api.sh /etc/service/api/run
COPY docker/api.sh /etc/service/api/run

RUN mkdir /etc/service/penhas-minion-worker
COPY penhas-minion-worker.sh /etc/service/penhas-minion-worker/run
COPY docker/penhas-minion-worker.sh /etc/service/penhas-minion-worker/run

COPY . /src

RUN chown 1000:1000 /src/ -R
27 changes: 27 additions & 0 deletions api/lib/Penhas/CEP/ViaCep.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package Penhas::CEP::Postmon;

use Moose::Role;
use feature 'state';

use Furl;
use JSON qw(decode_json);

sub name {'Postmon'}

sub _find {
state $ua = Furl->new(timeout => 20);

my $cep = pop;
my $res = $ua->get('https://viacep.com.br/ws/' . $cep . '/json/');

return unless $res->is_success;

my $r = eval { decode_json($res->content) } or return;

my $street = $r->{logradouro} || '';

return {street => $street, city => $r->{localidade}, district => $r->{bairro}, state => $r->{uf},
ibge => $r->{ibge}};
}

1;
10 changes: 8 additions & 2 deletions api/lib/Penhas/Controller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ sub validate_request_params {
my ($c, %fields) = @_;

my $params = $c->req->params->to_hash;
return validate_params($c, $params, %fields);
}

sub validate_params {
my ($c, $params, %fields) = @_;

my $tested = {};
foreach my $key (keys %fields) {
Expand Down Expand Up @@ -252,8 +257,9 @@ sub validate_request_params {
}

$tested->{$key} = $val;
if ($tested->{$key} eq '' && ($type eq 'Bool' || $type eq 'Int' || $type eq 'Num')) {
use DDP; p $val;
if (defined $tested->{$key} && $tested->{$key} eq '' && ($type eq 'Bool' || $type eq 'Int' || $type eq 'Num')) {
use DDP;
p $val;
$tested->{$key} = undef;

}
Expand Down
Loading
Loading