From 21d99a66f82e2edc7990d5d207e495f77f9c67b6 Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Sat, 3 Oct 2026 21:48:17 -0300 Subject: [PATCH 1/7] =?UTF-8?q?fix/dataload:=20adiciona=20op=C3=A7=C3=B5es?= =?UTF-8?q?=20de=20status=20do=20ciclo=20e=20l=C3=B3gica=20de=20gera=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- python/dataload.ipynb | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index eaae597..54eaf98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.env -.idea/ \ No newline at end of file +.idea/ +aplicar.py \ No newline at end of file diff --git a/python/dataload.ipynb b/python/dataload.ipynb index d22b14f..551c19b 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -83,6 +83,8 @@ "# utilitários\n", "quantidade_dependencias = [1, 2, 3, 4]\n", "\n", + "status_ciclo = ['PLANEJAMENTO', 'EXECUCAO', 'VERIFICACAO', 'PADRONIZACAO', 'CONCLUIDO', 'CANCELADO', 'PAUSADO']\n", + "\n", "provedores_email = ['gmail.com', 'hotmail.com', 'outlook.com', 'yahoo.com.br']\n", "\n", "tamanho_empresa = ['PEQUENA', 'MEDIA', 'GRANDE']\n", @@ -298,23 +300,27 @@ }, "outputs": [], "source": [ - "# informações do ciclo\n", + "# informacoes do ciclo\n", "dados_ciclo = []\n", "gestor_ciclo = pd.DataFrame(dados_colaborador).groupby('id_empresa').first().reset_index()\n", "\n", "for _, gestor in gestor_ciclo.iterrows():\n", - " dados_ciclo.append({\n", - " 'id_empresa': gestor['id_empresa'],\n", - " 'id_responsavel': gestor['id_usuario'],\n", - " 'id_ishikawa_mongo': uuid4(),\n", - " 'titulo': faker.sentence(nb_words=5),\n", - " 'descricao': faker.paragraph(nb_sentences=10),\n", - " 'status': 'CONCLUIDO',\n", - " 'data_inicio': faker.past_date(start_date='-1y'),\n", - " 'data_estimada_fim': faker.future_date(),\n", - " 'data_fim_real': faker.future_date(),\n", - " 'icone_url': choice(icone_ciclo_urls)\n", - " })" + " qtd_ciclos = 3 if gestor['id_empresa'] in [1, 2, 3] else randint(1, 3)\n", + "\n", + " for _ in range(qtd_ciclos):\n", + " status = choices(status_ciclo, weights=[25, 25, 25, 20, 3, 1, 1], k=1)[0]\n", + " dados_ciclo.append({\n", + " 'id_empresa': gestor['id_empresa'],\n", + " 'id_responsavel': gestor['id_usuario'],\n", + " 'id_ishikawa_mongo': uuid4(),\n", + " 'titulo': faker.sentence(nb_words=5),\n", + " 'descricao': faker.paragraph(nb_sentences=10),\n", + " 'status': status,\n", + " 'data_inicio': faker.past_date(start_date='-1y'),\n", + " 'data_estimada_fim': faker.future_date(),\n", + " 'data_fim_real': faker.future_date() if status == 'CONCLUIDO' else None,\n", + " 'icone_url': choice(icone_ciclo_urls)\n", + " })" ] }, { From c517b85418e622422e3d75f7e70f1b95f0dcf9e5 Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Sat, 3 Oct 2026 22:10:44 -0300 Subject: [PATCH 2/7] =?UTF-8?q?fix/dataload:=20atualiza=20constantes=20e?= =?UTF-8?q?=20l=C3=B3gica=20de=20gera=C3=A7=C3=A3o=20de=20dados=20para=20c?= =?UTF-8?q?olaboradores=20e=20ciclos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/dataload.ipynb | 221 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 191 insertions(+), 30 deletions(-) diff --git a/python/dataload.ipynb b/python/dataload.ipynb index 551c19b..827591a 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -2,14 +2,20 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.831863Z", "start_time": "2026-07-12T17:37:32.806752900Z" }, - "collapsed": true + "collapsed": true, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:14.977781Z", + "iopub.status.busy": "2026-10-04T01:05:14.977460Z", + "iopub.status.idle": "2026-10-04T01:05:16.774267Z", + "shell.execute_reply": "2026-10-04T01:05:16.772494Z" + } }, "outputs": [], "source": [ @@ -29,12 +35,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "50a7a23f67f5e48e", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.849378900Z", "start_time": "2026-07-12T17:37:32.833862400Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:16.778282Z", + "iopub.status.busy": "2026-10-04T01:05:16.777758Z", + "iopub.status.idle": "2026-10-04T01:05:17.496712Z", + "shell.execute_reply": "2026-10-04T01:05:17.495253Z" } }, "outputs": [], @@ -49,18 +61,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "5b307e990236d04c", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.873825500Z", "start_time": "2026-07-12T17:37:32.855390700Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:17.501078Z", + "iopub.status.busy": "2026-10-04T01:05:17.500590Z", + "iopub.status.idle": "2026-10-04T01:05:17.508462Z", + "shell.execute_reply": "2026-10-04T01:05:17.506627Z" } }, "outputs": [], "source": [ "# constantes\n", - "QTD_EMPRESAS = 20\n", + "QTD_EMPRESAS = 150\n", + "QTD_COLABORADORES_MIN = 20\n", + "QTD_COLABORADORES_MAX = 50\n", + "QTD_CICLOS_FIXOS = 10\n", + "QTD_CICLOS_MIN = 8\n", + "QTD_CICLOS_MAX = 15\n", + "QTD_PROBLEMAS_MIN = 4\n", + "QTD_PROBLEMAS_MAX = 12\n", + "QTD_TAREFAS_MIN = 5\n", + "QTD_TAREFAS_MAX = 20\n", + "QTD_EFEITOS_MIN = 4\n", + "QTD_EFEITOS_MAX = 20\n", "USUARIOS_FIXOS = {\n", " 1: ('Gabriel Pibbles', 'gabetvigna@gmail.com', 'TmKtk3dmZdcmOBUSfXexpFhLdCm2', 'ADMIN'),\n", " 2: ('Lucas Almeida Plebe', 'lucas.almeidacosta09@gmail.com', '8BQy7GRasKZSkoGjl91iom6vFlF3', 'COLABORADOR'),\n", @@ -70,12 +99,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "8d2e0a13f81ee6e7", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.899721300Z", "start_time": "2026-07-12T17:37:32.874826400Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:17.512382Z", + "iopub.status.busy": "2026-10-04T01:05:17.512023Z", + "iopub.status.idle": "2026-10-04T01:05:17.524504Z", + "shell.execute_reply": "2026-10-04T01:05:17.522108Z" } }, "outputs": [], @@ -112,12 +147,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "5c640d3265f55391", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.916971600Z", "start_time": "2026-07-12T17:37:32.902725200Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:17.530243Z", + "iopub.status.busy": "2026-10-04T01:05:17.529707Z", + "iopub.status.idle": "2026-10-04T01:05:17.541383Z", + "shell.execute_reply": "2026-10-04T01:05:17.539214Z" } }, "outputs": [], @@ -129,6 +170,15 @@ "def apenas_numeros(valor: str) -> str:\n", " return sub(r'\\D', '', valor)\n", "\n", + "cpfs_gerados = set()\n", + "\n", + "def gerar_cpf_unico() -> str:\n", + " cpf = apenas_numeros(faker.cpf())\n", + " while cpf in cpfs_gerados:\n", + " cpf = apenas_numeros(faker.cpf())\n", + " cpfs_gerados.add(cpf)\n", + " return cpf\n", + "\n", "def gerar_lista_ids(limite: int) -> list:\n", " return list(range(1, limite + 1))\n", "\n", @@ -145,12 +195,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "f763f6fd19c4eb63", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:37:32.942830900Z", "start_time": "2026-07-12T17:37:32.930284400Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:17.544849Z", + "iopub.status.busy": "2026-10-04T01:05:17.544491Z", + "iopub.status.idle": "2026-10-04T01:05:17.585100Z", + "shell.execute_reply": "2026-10-04T01:05:17.583696Z" } }, "outputs": [], @@ -207,12 +263,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "7fb98319d9671d77", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.560830600Z", "start_time": "2026-07-12T17:37:32.944827800Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:17.590332Z", + "iopub.status.busy": "2026-10-04T01:05:17.589650Z", + "iopub.status.idle": "2026-10-04T01:05:18.601173Z", + "shell.execute_reply": "2026-10-04T01:05:18.599623Z" } }, "outputs": [], @@ -260,7 +322,7 @@ " 'nickname': nome,\n", " 'id_empresa': empresa_usuario,\n", " 'id_usuario': id,\n", - " 'cpf': apenas_numeros(faker.cpf()),\n", + " 'cpf': gerar_cpf_unico(),\n", " 'cargo': faker.job()[:100],\n", " 'area': choice(areas),\n", " 'data_nascimento': faker.date_of_birth(minimum_age=18, maximum_age=70),\n", @@ -276,7 +338,7 @@ "\n", "id = 1\n", "for id_empresa in lista_id_empresa:\n", - " qtd_colaboradores = randint(4, 29)\n", + " qtd_colaboradores = randint(QTD_COLABORADORES_MIN, QTD_COLABORADORES_MAX)\n", "\n", " # gerar gestor\n", " gerar_colaborador(id_empresa, 'GESTOR', id)\n", @@ -290,12 +352,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "a79912991e1fa0fe", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.639126800Z", "start_time": "2026-07-12T17:38:16.607711700Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:18.604468Z", + "iopub.status.busy": "2026-10-04T01:05:18.604108Z", + "iopub.status.idle": "2026-10-04T01:05:18.988004Z", + "shell.execute_reply": "2026-10-04T01:05:18.986375Z" } }, "outputs": [], @@ -305,7 +373,7 @@ "gestor_ciclo = pd.DataFrame(dados_colaborador).groupby('id_empresa').first().reset_index()\n", "\n", "for _, gestor in gestor_ciclo.iterrows():\n", - " qtd_ciclos = 3 if gestor['id_empresa'] in [1, 2, 3] else randint(1, 3)\n", + " qtd_ciclos = QTD_CICLOS_FIXOS if gestor['id_empresa'] in [1, 2, 3] else randint(QTD_CICLOS_MIN, QTD_CICLOS_MAX)\n", "\n", " for _ in range(qtd_ciclos):\n", " status = choices(status_ciclo, weights=[25, 25, 25, 20, 3, 1, 1], k=1)[0]\n", @@ -325,12 +393,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "fbbdaf0803f052ce", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.658350700Z", "start_time": "2026-07-12T17:38:16.649332Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:18.992219Z", + "iopub.status.busy": "2026-10-04T01:05:18.991826Z", + "iopub.status.idle": "2026-10-04T01:05:19.228697Z", + "shell.execute_reply": "2026-10-04T01:05:19.226464Z" } }, "outputs": [], @@ -372,12 +446,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "bc0e3a2cb9897c5c", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.670638900Z", "start_time": "2026-07-12T17:38:16.660829800Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:19.232691Z", + "iopub.status.busy": "2026-10-04T01:05:19.232316Z", + "iopub.status.idle": "2026-10-04T01:05:20.444256Z", + "shell.execute_reply": "2026-10-04T01:05:20.442385Z" } }, "outputs": [], @@ -387,7 +467,7 @@ "id_problema = 1\n", "\n", "for id_ciclo, ciclo in enumerate(dados_ciclo, start=1):\n", - " qtd_problema = randint(1, 5)\n", + " qtd_problema = randint(QTD_PROBLEMAS_MIN, QTD_PROBLEMAS_MAX)\n", "\n", " for i in range(qtd_problema):\n", " dados_problema.append({\n", @@ -410,12 +490,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "5531d480b5fcddac", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.685420900Z", "start_time": "2026-07-12T17:38:16.672640500Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:20.448337Z", + "iopub.status.busy": "2026-10-04T01:05:20.447908Z", + "iopub.status.idle": "2026-10-04T01:05:21.595022Z", + "shell.execute_reply": "2026-10-04T01:05:21.593544Z" } }, "outputs": [], @@ -440,12 +526,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "75679ba628965064", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.714712600Z", "start_time": "2026-07-12T17:38:16.699837500Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:21.599343Z", + "iopub.status.busy": "2026-10-04T01:05:21.598969Z", + "iopub.status.idle": "2026-10-04T01:05:21.736657Z", + "shell.execute_reply": "2026-10-04T01:05:21.734463Z" } }, "outputs": [], @@ -468,12 +560,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "914fe4148f0e775", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.727891900Z", "start_time": "2026-07-12T17:38:16.716743100Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:21.742534Z", + "iopub.status.busy": "2026-10-04T01:05:21.741964Z", + "iopub.status.idle": "2026-10-04T01:05:23.279618Z", + "shell.execute_reply": "2026-10-04T01:05:23.275083Z" } }, "outputs": [], @@ -482,7 +580,7 @@ "dados_tarefa = []\n", "\n", "for id_plano_acao, plano_acao in enumerate(dados_plano_acao, start=1):\n", - " for _ in range(randint(1, 10)):\n", + " for _ in range(randint(QTD_TAREFAS_MIN, QTD_TAREFAS_MAX)):\n", " dados_tarefa.append({\n", " 'id_plano_acao': id_plano_acao,\n", " 'id_responsavel': plano_acao['criado_por'],\n", @@ -496,12 +594,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "f1f1226dc957c543", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.740852Z", "start_time": "2026-07-12T17:38:16.729201Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:23.289313Z", + "iopub.status.busy": "2026-10-04T01:05:23.288434Z", + "iopub.status.idle": "2026-10-04T01:05:23.467126Z", + "shell.execute_reply": "2026-10-04T01:05:23.462729Z" } }, "outputs": [], @@ -522,12 +626,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "553d833704f121cf", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.752311500Z", "start_time": "2026-07-12T17:38:16.742923900Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:23.475900Z", + "iopub.status.busy": "2026-10-04T01:05:23.474617Z", + "iopub.status.idle": "2026-10-04T01:05:23.546659Z", + "shell.execute_reply": "2026-10-04T01:05:23.543074Z" } }, "outputs": [], @@ -547,12 +657,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "de1c8d58b118b9f6", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.766388400Z", "start_time": "2026-07-12T17:38:16.755314200Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:23.552723Z", + "iopub.status.busy": "2026-10-04T01:05:23.552217Z", + "iopub.status.idle": "2026-10-04T01:05:24.404984Z", + "shell.execute_reply": "2026-10-04T01:05:24.402352Z" } }, "outputs": [], @@ -561,7 +677,7 @@ "dados_efeito_secundario = []\n", "\n", "for id_verificacao, verificacao in enumerate(dados_verificacao, start=1):\n", - " for _ in range(randint(1, 10)):\n", + " for _ in range(randint(QTD_EFEITOS_MIN, QTD_EFEITOS_MAX)):\n", " dados_efeito_secundario.append({\n", " 'id_verificacao_resultado': id_verificacao,\n", " 'descricao': faker.sentence(nb_words=10),\n", @@ -573,12 +689,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "5fe35937f40bd1ef", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.790710700Z", "start_time": "2026-07-12T17:38:16.768392800Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:24.410746Z", + "iopub.status.busy": "2026-10-04T01:05:24.410246Z", + "iopub.status.idle": "2026-10-04T01:05:24.686446Z", + "shell.execute_reply": "2026-10-04T01:05:24.681567Z" } }, "outputs": [], @@ -606,12 +728,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "4ade28691351ca02", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.812063100Z", "start_time": "2026-07-12T17:38:16.792704900Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:24.691899Z", + "iopub.status.busy": "2026-10-04T01:05:24.691401Z", + "iopub.status.idle": "2026-10-04T01:05:33.933255Z", + "shell.execute_reply": "2026-10-04T01:05:33.929618Z" } }, "outputs": [], @@ -681,12 +809,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "8fbc0604c8d1afb2", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.841613600Z", "start_time": "2026-07-12T17:38:16.815060900Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:33.941881Z", + "iopub.status.busy": "2026-10-04T01:05:33.940899Z", + "iopub.status.idle": "2026-10-04T01:05:33.959240Z", + "shell.execute_reply": "2026-10-04T01:05:33.955165Z" } }, "outputs": [], @@ -719,12 +853,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "627beae77ba3737d", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:16.859731300Z", "start_time": "2026-07-12T17:38:16.843629600Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:33.967362Z", + "iopub.status.busy": "2026-10-04T01:05:33.966679Z", + "iopub.status.idle": "2026-10-04T01:05:33.979369Z", + "shell.execute_reply": "2026-10-04T01:05:33.975188Z" } }, "outputs": [], @@ -735,15 +875,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "75085470c5a76148", "metadata": { "ExecuteTime": { "end_time": "2026-07-12T17:38:17.163562400Z", "start_time": "2026-07-12T17:38:16.860730900Z" + }, + "execution": { + "iopub.execute_input": "2026-10-04T01:05:33.986875Z", + "iopub.status.busy": "2026-10-04T01:05:33.986123Z", + "iopub.status.idle": "2026-10-04T01:09:36.562149Z", + "shell.execute_reply": "2026-10-04T01:09:36.560084Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iniciando conexão com o banco de dados\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Conexão com o banco de dados finalizada com sucesso\n" + ] + } + ], "source": [ "print('Iniciando conexão com o banco de dados')\n", "for (schema, tabela), df in tabelas.items():\n", From d94fea0409fb4357800ba4e00890acd851527761 Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Sun, 4 Oct 2026 09:53:36 -0300 Subject: [PATCH 3/7] =?UTF-8?q?fix/dataload:=20redefine=20contagem=20de=20?= =?UTF-8?q?execu=C3=A7=C3=A3o=20para=20menos=20gastos=20no=20neon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/dataload.ipynb | 83 ++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/python/dataload.ipynb b/python/dataload.ipynb index 827591a..4f7e5af 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "initial_id", "metadata": { "ExecuteTime": { @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "50a7a23f67f5e48e", "metadata": { "ExecuteTime": { @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "5b307e990236d04c", "metadata": { "ExecuteTime": { @@ -78,18 +78,18 @@ "outputs": [], "source": [ "# constantes\n", - "QTD_EMPRESAS = 150\n", - "QTD_COLABORADORES_MIN = 20\n", - "QTD_COLABORADORES_MAX = 50\n", - "QTD_CICLOS_FIXOS = 10\n", - "QTD_CICLOS_MIN = 8\n", - "QTD_CICLOS_MAX = 15\n", - "QTD_PROBLEMAS_MIN = 4\n", - "QTD_PROBLEMAS_MAX = 12\n", - "QTD_TAREFAS_MIN = 5\n", - "QTD_TAREFAS_MAX = 20\n", - "QTD_EFEITOS_MIN = 4\n", - "QTD_EFEITOS_MAX = 20\n", + "QTD_EMPRESAS = 10\n", + "QTD_COLABORADORES_MIN = 5\n", + "QTD_COLABORADORES_MAX = 10\n", + "QTD_CICLOS_FIXOS = 3\n", + "QTD_CICLOS_MIN = 1\n", + "QTD_CICLOS_MAX = 3\n", + "QTD_PROBLEMAS_MIN = 1\n", + "QTD_PROBLEMAS_MAX = 3\n", + "QTD_TAREFAS_MIN = 1\n", + "QTD_TAREFAS_MAX = 3\n", + "QTD_EFEITOS_MIN = 1\n", + "QTD_EFEITOS_MAX = 5\n", "USUARIOS_FIXOS = {\n", " 1: ('Gabriel Pibbles', 'gabetvigna@gmail.com', 'TmKtk3dmZdcmOBUSfXexpFhLdCm2', 'ADMIN'),\n", " 2: ('Lucas Almeida Plebe', 'lucas.almeidacosta09@gmail.com', '8BQy7GRasKZSkoGjl91iom6vFlF3', 'COLABORADOR'),\n", @@ -99,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "8d2e0a13f81ee6e7", "metadata": { "ExecuteTime": { @@ -147,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "5c640d3265f55391", "metadata": { "ExecuteTime": { @@ -195,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "f763f6fd19c4eb63", "metadata": { "ExecuteTime": { @@ -263,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "7fb98319d9671d77", "metadata": { "ExecuteTime": { @@ -352,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "a79912991e1fa0fe", "metadata": { "ExecuteTime": { @@ -393,7 +393,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "fbbdaf0803f052ce", "metadata": { "ExecuteTime": { @@ -446,7 +446,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "bc0e3a2cb9897c5c", "metadata": { "ExecuteTime": { @@ -490,7 +490,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "5531d480b5fcddac", "metadata": { "ExecuteTime": { @@ -526,7 +526,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "75679ba628965064", "metadata": { "ExecuteTime": { @@ -560,7 +560,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "914fe4148f0e775", "metadata": { "ExecuteTime": { @@ -594,7 +594,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "id": "f1f1226dc957c543", "metadata": { "ExecuteTime": { @@ -626,7 +626,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "id": "553d833704f121cf", "metadata": { "ExecuteTime": { @@ -657,7 +657,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "id": "de1c8d58b118b9f6", "metadata": { "ExecuteTime": { @@ -689,7 +689,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "id": "5fe35937f40bd1ef", "metadata": { "ExecuteTime": { @@ -728,7 +728,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "id": "4ade28691351ca02", "metadata": { "ExecuteTime": { @@ -809,7 +809,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "id": "8fbc0604c8d1afb2", "metadata": { "ExecuteTime": { @@ -853,7 +853,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "id": "627beae77ba3737d", "metadata": { "ExecuteTime": { @@ -875,7 +875,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "id": "75085470c5a76148", "metadata": { "ExecuteTime": { @@ -889,22 +889,7 @@ "shell.execute_reply": "2026-10-04T01:09:36.560084Z" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Iniciando conexão com o banco de dados\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Conexão com o banco de dados finalizada com sucesso\n" - ] - } - ], + "outputs": [], "source": [ "print('Iniciando conexão com o banco de dados')\n", "for (schema, tabela), df in tabelas.items():\n", From 6a89586fc56e404c4bd52634c1aea635cc3928c0 Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Sun, 4 Oct 2026 20:17:24 -0300 Subject: [PATCH 4/7] =?UTF-8?q?fix/dataload:=20adiciona=20tipo=20de=20dado?= =?UTF-8?q?=20'data=5Ffim=5Freal'=20e=20corrige=20importa=C3=A7=C3=A3o=20d?= =?UTF-8?q?e=20'Date'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/dataload.ipynb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/dataload.ipynb b/python/dataload.ipynb index 4f7e5af..0f7c28f 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -25,7 +25,7 @@ "from dotenv import load_dotenv\n", "from faker import Faker\n", "import pandas as pd\n", - "from sqlalchemy import create_engine, text\n", + "from sqlalchemy import Date, create_engine, text\n", "from sqlalchemy.dialects.postgresql import UUID\n", "from re import sub\n", "from unicodedata import normalize\n", @@ -898,7 +898,10 @@ " conn.execute(text(\"SET LOCAL app.current_user_id = '0'\"))\n", " dtype = None\n", " if (schema, tabela) == ('pdca', 'ciclo'):\n", - " dtype = {'id_ishikawa_mongo': UUID(as_uuid=True)}\n", + " dtype = {\n", + " 'id_ishikawa_mongo': UUID(as_uuid=True),\n", + " 'data_fim_real': Date()\n", + " }\n", " elif (schema, tabela) == ('pdca', 'causa_raiz'):\n", " dtype = {'id_5_porques_mongo': UUID(as_uuid=True)}\n", " df.to_sql(name = tabela, schema = schema, con = conn, if_exists = 'append', index = False, dtype = dtype)\n", From 245bbf39edda00ebd6d78d9aa16a7892fec1e1bb Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Tue, 6 Oct 2026 08:09:01 -0300 Subject: [PATCH 5/7] =?UTF-8?q?fix/sql:=20adiciona=20colunas=20'colaborado?= =?UTF-8?q?res=5Fpodem=5Feditar'=20e=20'id=5Fultima=5Falteracao=5Fpor'=20n?= =?UTF-8?q?a=20tabela=20'plano=5F5w2h'=20com=20coment=C3=A1rios=20e=20inse?= =?UTF-8?q?r=C3=A7=C3=B5es=20no=20cat=C3=A1logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/001_script.sql | 2 ++ sql/007_comments.sql | 2 ++ sql/008_catalogo.sql | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sql/001_script.sql b/sql/001_script.sql index 36bfe8e..bdea6dc 100644 --- a/sql/001_script.sql +++ b/sql/001_script.sql @@ -238,6 +238,8 @@ CREATE TABLE IF NOT EXISTS pdca.plano_5w2h ( when_fim DATE NOT NULL, how_modo_execucao TEXT NOT NULL, how_much_custo NUMERIC(12,2) NOT NULL CHECK (how_much_custo >= 0), + colaboradores_podem_editar BOOLEAN NOT NULL DEFAULT FALSE, + id_ultima_alteracao_por BIGINT REFERENCES usuario_sistema(id), criado_em TIMESTAMPTZ NOT NULL DEFAULT NOW(), atualizado_em TIMESTAMPTZ, CONSTRAINT plano_5w2h_datas_check CHECK (when_inicio IS NULL OR when_fim >= when_inicio) diff --git a/sql/007_comments.sql b/sql/007_comments.sql index f4e1d64..83ad76e 100644 --- a/sql/007_comments.sql +++ b/sql/007_comments.sql @@ -198,6 +198,8 @@ COMMENT ON COLUMN pdca.plano_5w2h.when_inicio IS 'Data de inicio da acao.'; COMMENT ON COLUMN pdca.plano_5w2h.when_fim IS 'Data de fim planejada da acao.'; COMMENT ON COLUMN pdca.plano_5w2h.how_modo_execucao IS 'Como a acao sera executada.'; COMMENT ON COLUMN pdca.plano_5w2h.how_much_custo IS 'Custo estimado da acao.'; +COMMENT ON COLUMN pdca.plano_5w2h.colaboradores_podem_editar IS 'Indica se colaboradores do ciclo podem editar o 5W2H.'; +COMMENT ON COLUMN pdca.plano_5w2h.id_ultima_alteracao_por IS 'Usuario que realizou a ultima alteracao no 5W2H.'; COMMENT ON COLUMN pdca.plano_5w2h.criado_em IS 'Data e hora de criacao do registro.'; COMMENT ON COLUMN pdca.plano_5w2h.atualizado_em IS 'Data e hora da ultima atualizacao do registro.'; diff --git a/sql/008_catalogo.sql b/sql/008_catalogo.sql index 04410e8..7cee72a 100644 --- a/sql/008_catalogo.sql +++ b/sql/008_catalogo.sql @@ -205,6 +205,8 @@ INSERT INTO auditoria.catalogo_dados ( ('pdca', 'plano_5w2h', 'when_fim', 'DATE', FALSE, FALSE, NULL, TRUE, 'Data limite (When). Deve ser >= when_inicio se este for informado.', 'INTERNO', 'Data de fim planejada da ação.'), ('pdca', 'plano_5w2h', 'how_modo_execucao', 'TEXT', FALSE, FALSE, NULL, TRUE, 'Método (How).', 'INTERNO', 'Como a ação será executada.'), ('pdca', 'plano_5w2h', 'how_much_custo', 'NUMERIC(12,2)', FALSE, FALSE, NULL, TRUE, 'Custo monetário (How much). Deve ser >= 0.', 'SENSIVEL', 'Custo estimado da ação.'), +('pdca', 'plano_5w2h', 'colaboradores_podem_editar', 'BOOLEAN', FALSE, FALSE, NULL, TRUE, 'Valor padrão FALSE. Controla a edição por colaboradores do ciclo.', 'INTERNO', 'Indica se colaboradores do ciclo podem editar o 5W2H.'), +('pdca', 'plano_5w2h', 'id_ultima_alteracao_por', 'BIGINT', FALSE, TRUE, 'public.usuario_sistema(id)', FALSE, 'Usuário que realizou a última alteração no 5W2H.', 'INTERNO', 'Identifica o usuário responsável pela última alteração.'), ('pdca', 'plano_5w2h', 'criado_em', 'TIMESTAMPTZ', FALSE, FALSE, NULL, TRUE, 'Valor padrão NOW().', 'INTERNO', 'Data e hora de criação do registro.'), ('pdca', 'plano_5w2h', 'atualizado_em', 'TIMESTAMPTZ', FALSE, FALSE, NULL, FALSE, 'Data da última edição.', 'INTERNO', 'Data e hora da última atualização do registro.'), From bb6262aea695747599628e4c9845690e891d811f Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Tue, 6 Oct 2026 08:11:39 -0300 Subject: [PATCH 6/7] =?UTF-8?q?fix/dataload:=20adiciona=20fun=C3=A7=C3=B5e?= =?UTF-8?q?s=20para=20gera=C3=A7=C3=A3o=20de=20datas=20aleat=C3=B3rias=20e?= =?UTF-8?q?=20atualiza=20l=C3=B3gica=20de=20atribui=C3=A7=C3=A3o=20de=20da?= =?UTF-8?q?tas=20em=20registros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/dataload.ipynb | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/python/dataload.ipynb b/python/dataload.ipynb index 0f7c28f..83b8bd1 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -21,7 +21,8 @@ "source": [ "# fazendo importações\n", "import os\n", - "from random import choice, choices, randint, triangular\n", + "from random import choice, choices, randint, triangular\n", + "from datetime import date, timedelta\n", "from dotenv import load_dotenv\n", "from faker import Faker\n", "import pandas as pd\n", @@ -56,7 +57,18 @@ "\n", "DATABASE_URL = os.getenv(\"URL_SEGUNDO_BANCO\")\n", "engine = create_engine(DATABASE_URL)\n", - "faker = Faker(\"pt_BR\")" + "faker = Faker(\"pt_BR\")\n", + "hoje = date.today()\n", + "inicio_periodo = hoje - timedelta(days=730)\n", + "\n", + "def data_aleatoria(inicio=inicio_periodo, fim=hoje):\n", + " return faker.date_between_dates(date_start=inicio, date_end=fim)\n", + "\n", + "def data_prazo(inicio=inicio_periodo, fim=hoje):\n", + " data_base = data_aleatoria(inicio, fim)\n", + " if data_base < hoje and choice([True, False]):\n", + " return data_base + timedelta(days=randint(1, min(120, (hoje - data_base).days)))\n", + " return data_base + timedelta(days=randint(7, 120))" ] }, { @@ -326,7 +338,7 @@ " 'cargo': faker.job()[:100],\n", " 'area': choice(areas),\n", " 'data_nascimento': faker.date_of_birth(minimum_age=18, maximum_age=70),\n", - " 'data_contratacao': faker.date_this_decade(),\n", + " 'data_contratacao': data_aleatoria(date(hoje.year - 10, 1, 1), hoje),\n", " 'permissao_gestor': True if tipo == 'GESTOR' or tipo == 'ADMIN' else False,\n", " 'status': 'ATIVO'\n", " })\n", @@ -384,9 +396,9 @@ " 'titulo': faker.sentence(nb_words=5),\n", " 'descricao': faker.paragraph(nb_sentences=10),\n", " 'status': status,\n", - " 'data_inicio': faker.past_date(start_date='-1y'),\n", - " 'data_estimada_fim': faker.future_date(),\n", - " 'data_fim_real': faker.future_date() if status == 'CONCLUIDO' else None,\n", + " 'data_inicio': (data_inicio := data_aleatoria()),\n", + " 'data_estimada_fim': data_prazo(data_inicio),\n", + " 'data_fim_real': data_aleatoria(data_inicio) if status == 'CONCLUIDO' else None,\n", " 'icone_url': choice(icone_ciclo_urls)\n", " })" ] @@ -434,7 +446,7 @@ " 'valor_base': randint(1000, 100000),\n", " 'valor_alvo': randint(1000, 100000),\n", " 'unidade': choice(['R$', 'US$', 'EUR']),\n", - " 'prazo': faker.future_date(),\n", + " 'prazo': data_prazo(),\n", " 'status': choice(['PARCIALMENTE_ATINGIDA', 'ATINGIDA', 'NAO_ATINGIDA']),\n", " 'prioridade': choice(['BAIXA', 'MEDIA', 'ALTA', 'CRITICA']),\n", " 'area': choice(areas),\n", @@ -552,7 +564,7 @@ " 'what_acao': faker.sentence(nb_words=10),\n", " 'why_justificativa': faker.sentence(nb_words=10),\n", " 'where_local': faker.sentence(nb_words=10),\n", - " 'when_fim': faker.future_date(),\n", + " 'when_fim': data_prazo(),\n", " 'how_modo_execucao': faker.sentence(nb_words=10),\n", " 'how_much_custo': randint(1000, 100000),\n", " })" @@ -588,7 +600,7 @@ " 'descricao': faker.sentence(nb_words=10),\n", " 'prioridade': choice(['BAIXA', 'MEDIA', 'ALTA', 'CRITICA']),\n", " 'status': 'PENDENTE',\n", - " 'data_fim_prevista': faker.future_date()\n", + " 'data_fim_prevista': data_prazo()\n", " })" ] }, @@ -619,7 +631,7 @@ " 'id_responsavel': ciclo['id_responsavel'],\n", " 'titulo': faker.sentence(nb_words=5),\n", " 'descricao': faker.sentence(nb_words=10),\n", - " 'data_treinamento': faker.future_date(),\n", + " 'data_treinamento': data_prazo(),\n", " 'obrigatorio': choice([True, False])\n", " })" ] @@ -783,8 +795,8 @@ " 'id_treinamento': id_treinamento,\n", " 'id_usuario': id_usuario,\n", " 'obrigatorio': treinamento['obrigatorio'],\n", - " 'status': choice(['PENDENTE', 'CONFIRMADO', 'CONCLUIDO']),\n", - " 'terminado_em': faker.future_date()\n", + " 'status': (status_treinamento := choice(['PENDENTE', 'CONFIRMADO', 'CONCLUIDO'])),\n", + " 'terminado_em': data_aleatoria() if status_treinamento == 'CONCLUIDO' else None\n", " })\n", "\n", "for problema in dados_problema:\n", @@ -913,7 +925,7 @@ " except Exception as e:\n", " print(f'Um erro no banco de dados ocorreu: {e}')\n", " raise\n", - "print('Conexão com o banco de dados finalizada com sucesso')\n" + "print('Conexão com o banco de dados finalizada com sucesso')" ] } ], From 13fa54f3ec611d5ab0e0e2a7d73e4552167a9361 Mon Sep 17 00:00:00 2001 From: Davi Aliaga Date: Tue, 6 Oct 2026 08:14:39 -0300 Subject: [PATCH 7/7] =?UTF-8?q?fix/dataload:=20atualiza=20op=C3=A7=C3=B5es?= =?UTF-8?q?=20de=20status=20na=20gera=C3=A7=C3=A3o=20de=20dados=20para=20i?= =?UTF-8?q?ncluir=20m=C3=BAltiplos=20estados=20poss=C3=ADveis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/dataload.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/dataload.ipynb b/python/dataload.ipynb index 83b8bd1..d5f2538 100644 --- a/python/dataload.ipynb +++ b/python/dataload.ipynb @@ -599,7 +599,7 @@ " 'titulo': faker.sentence(nb_words=5),\n", " 'descricao': faker.sentence(nb_words=10),\n", " 'prioridade': choice(['BAIXA', 'MEDIA', 'ALTA', 'CRITICA']),\n", - " 'status': 'PENDENTE',\n", + " 'status': choice(['PENDENTE', 'EM_ANDAMENTO', 'BLOQUEADA', 'CONCLUIDA', 'ATRASADA', 'CANCELADA']),\n", " 'data_fim_prevista': data_prazo()\n", " })" ]