[SCRUM-52] Pipeline de auto-apply de sugestoes de relatorio#37
Draft
notsogreatdavi wants to merge 10 commits intodevfrom
Draft
[SCRUM-52] Pipeline de auto-apply de sugestoes de relatorio#37notsogreatdavi wants to merge 10 commits intodevfrom
notsogreatdavi wants to merge 10 commits intodevfrom
Conversation
Contributor
Guilherme-leo
requested changes
Apr 26, 2026
Collaborator
Guilherme-leo
left a comment
There was a problem hiding this comment.
Assim como conversado na última reunião, será necessário bloquearmos essa task por enquanto, devido às funcionalidades, entidades e informações que serão adicionadas nos épicos posteriores, bem como às possíveis alterações nos épicos já desenvolvidos quando integrados ao frontend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Objetivo
Implementa o pipeline completo de auto-apply para a SCRUM-52: permite aplicar sugestoes de melhoria (geradas por relatorio IA) diretamente nos dados da empresa e do cardapio, tanto de forma individual quanto em lote a partir de um relatorio existente.
📁 Arquivos Criados
app/core/exceptions.pyapp/schemas/auto_apply.pyapp/services/auto_apply_service.pyapp/services/report_auto_apply_service.pyapp/routers/auto_apply.pytests/test_auto_apply_service.pytests/test_report_auto_apply_service.pytests/test_auto_apply_router.py✏️ Arquivos Alterados
app/main.pyapp/routers/reports.pyapp/services/report_service.pytests/test_reports_router.py🧪 Como Testar
Pré-requisitos
Teste 1: Auto-apply individual (POST /auto-apply)
POST /auto-apply{ "enterprise_id": "<UUID da empresa>", "target": "enterprise", "campo_para_alterar": "historia", "novo_valor": "Restaurante familiar fundado em 2010 no sertao pernambucano" }200com body{"campo_alterado": "historia", "status": "aplicado"}GET /enterprises/{id}que o campohistoriafoi atualizadoTeste 2: Auto-apply de item do cardapio (POST /auto-apply)
menu_item:{ "enterprise_id": "<UUID da empresa>", "target": "menu_item", "menu_item_id": "<UUID do item de cardapio>", "campo_para_alterar": "preco", "novo_valor": "25.90" }200com{"campo_alterado": "preco", "status": "aplicado"}Teste 3: Campo nao permitido (POST /auto-apply)
"campo_para_alterar": "owner_id")422com mensagem"Campo não permitido para alteração automática: owner_id"Teste 4: Auto-apply em lote a partir de relatorio (POST /reports/{report_id}/auto-apply)
POST /reports/generate/{empresa_id}e copiar oid_relatorioretornadoPOST /reports/{report_id}/auto-applyreport_id200com body contendo:report_id: UUID do relatoriototal: quantidade de sugestoes extraidas pela IAaplicadas: quantas foram aplicadas com sucessorejeitadas: quantas falharam (campo invalido, entidade nao encontrada, etc.)resultados: lista detalhada com cada sugestao, seu status (aplicado/rejeitado) e mensagem de erro quando rejeitadaGET /enterprises/{id}eGET /menus/{id}que os campos aplicados foram atualizadosTeste 5: Relatorio inexistente (POST /reports/{report_id}/auto-apply)
report_id404com mensagem"Relatório IA não encontrado: <UUID>"Testes automatizados