From 5d1e7876be6bd422f176705c042e7ffd5499bb24 Mon Sep 17 00:00:00 2001 From: Sidney Date: Thu, 30 Apr 2026 20:17:26 -0300 Subject: [PATCH] =?UTF-8?q?build:=20for=C3=A7ando=20atualiza=C3=A7=C3=A3o?= =?UTF-8?q?=20do=20sistema=20de=20notas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/scratch/check_pastas.js | 37 ++++++++++++++++++++++++++++++ manager/scratch/debug_migration.js | 20 ++++++++++++++++ manager/scratch/deep_debug.js | 29 +++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 manager/scratch/check_pastas.js create mode 100644 manager/scratch/debug_migration.js create mode 100644 manager/scratch/deep_debug.js diff --git a/manager/scratch/check_pastas.js b/manager/scratch/check_pastas.js new file mode 100644 index 0000000..60824be --- /dev/null +++ b/manager/scratch/check_pastas.js @@ -0,0 +1,37 @@ +import pg from 'pg'; +const DATABASE_URL = 'postgresql://edumanager:EduManager2026!Seguro@localhost:5432/edumanager'; +const pool = new pg.Pool({ connectionString: DATABASE_URL }); + +async function checkExams() { + try { + const { rows } = await pool.query('SELECT data FROM school_data WHERE id = 1'); + const data = rows[0]?.data || {}; + const exams = data.exams || []; + + const pastaExam = exams.find(e => e.title && e.title.includes('Pastas')); + + if (pastaExam) { + console.log('--- Atividade Encontrada ---'); + console.log('Título:', pastaExam.title); + console.log('ID:', pastaExam.id); + console.log('subjectId:', pastaExam.subjectId); + console.log('periodId:', pastaExam.periodId); + console.log('Status:', pastaExam.status); + + if (!pastaExam.subjectId || !pastaExam.periodId) { + console.log('❌ ALERTA: Esta atividade está DESCONECTADA (sem subjectId ou periodId).'); + } else { + console.log('✅ OK: Esta atividade está vinculada corretamente.'); + } + } else { + console.log('❌ Atividade "Pastas" não encontrada no school_data.'); + console.log('Títulos disponíveis:', exams.map(e => e.title)); + } + + } catch (err) { + console.error('Erro na verificação:', err.message); + } finally { + await pool.end(); + } +} +checkExams(); diff --git a/manager/scratch/debug_migration.js b/manager/scratch/debug_migration.js new file mode 100644 index 0000000..77042ca --- /dev/null +++ b/manager/scratch/debug_migration.js @@ -0,0 +1,20 @@ +import pg from 'pg'; +const DATABASE_URL = 'postgresql://edumanager:EduManager2026!Seguro@localhost:5432/edumanager'; +const pool = new pg.Pool({ connectionString: DATABASE_URL }); + +async function check() { + try { + const { rows: notas } = await pool.query('SELECT count(*) FROM notas_boletim'); + console.log('Notas count in table:', notas[0].count); + + const { rows: sd } = await pool.query('SELECT data FROM school_data WHERE id = 1'); + const data = sd[0]?.data || {}; + console.log('Grades count in JSON:', data.grades?.length || 0); + + } catch (err) { + console.error('Error during check:', err.message); + } finally { + await pool.end(); + } +} +check(); diff --git a/manager/scratch/deep_debug.js b/manager/scratch/deep_debug.js new file mode 100644 index 0000000..acef5f1 --- /dev/null +++ b/manager/scratch/deep_debug.js @@ -0,0 +1,29 @@ +import pg from 'pg'; +const DATABASE_URL = 'postgresql://edumanager:EduManager2026!Seguro@127.0.0.1:5432/edumanager'; +const pool = new pg.Pool({ connectionString: DATABASE_URL }); + +async function debug() { + try { + const { rows: schoolRows } = await pool.query('SELECT data FROM school_data WHERE id = 1'); + const data = schoolRows[0]?.data || {}; + const sidney = (data.students || []).find(s => s.name && s.name.includes('Sidney')); + + if (!sidney) { + console.log('Sidney não encontrado no JSON.'); + } else { + console.log('ID do Sidney:', sidney.id); + const { rows: notas } = await pool.query('SELECT * FROM notas_boletim WHERE aluno_id = $1', [sidney.id]); + console.log('Notas na tabela SQL:', notas.length); + console.log(JSON.stringify(notas, null, 2)); + } + + const { rows: allNotas } = await pool.query('SELECT count(*) FROM notas_boletim'); + console.log('Total de notas na tabela SQL:', allNotas[0].count); + + } catch (err) { + console.error('ERRO:', err.message); + } finally { + await pool.end(); + } +} +debug();