fix(frequencias): apply TO_CHAR for sql date formatting to prevent timezone shifts matching bugs
This commit is contained in:
parent
1932807479
commit
c5d2979b60
|
|
@ -822,13 +822,16 @@ export async function deleteAulas(ids) {
|
|||
// FREQUÊNCIAS (CHAMADA)
|
||||
// ============================================================
|
||||
export async function getFrequencias() {
|
||||
const { rows } = await pool.query('SELECT * FROM frequencias ORDER BY created_at DESC');
|
||||
const { rows } = await pool.query(`
|
||||
SELECT *, TO_CHAR(data, 'YYYY-MM-DD"T"HH24:MI:SS') as formatted_data
|
||||
FROM frequencias ORDER BY created_at DESC
|
||||
`);
|
||||
return rows.map(r => ({
|
||||
id: r.id,
|
||||
studentId: r.aluno_id,
|
||||
classId: r.turma_id,
|
||||
lessonId: r.aula_id,
|
||||
date: r.data,
|
||||
date: r.formatted_data || r.data,
|
||||
photo: r.foto,
|
||||
verified: r.verificado,
|
||||
type: r.tipo,
|
||||
|
|
|
|||
|
|
@ -512,7 +512,8 @@ app.get('/api/portal/notas', authMiddleware, async (req, res) => {
|
|||
app.get('/api/portal/frequencia', authMiddleware, async (req, res) => {
|
||||
try {
|
||||
const { rows } = await pool.query(
|
||||
`SELECT * FROM frequencias WHERE aluno_id = $1 ORDER BY data DESC`,
|
||||
`SELECT *, TO_CHAR(data, 'YYYY-MM-DD"T"HH24:MI:SS') as formatted_data
|
||||
FROM frequencias WHERE aluno_id = $1 ORDER BY data DESC`,
|
||||
[req.user.studentId]
|
||||
);
|
||||
|
||||
|
|
@ -521,7 +522,7 @@ app.get('/api/portal/frequencia', authMiddleware, async (req, res) => {
|
|||
studentId: r.aluno_id,
|
||||
classId: r.turma_id,
|
||||
lessonId: r.aula_id,
|
||||
date: r.data,
|
||||
date: r.formatted_data || r.data,
|
||||
photo: r.foto_url || r.foto,
|
||||
verified: r.verificado,
|
||||
type: r.tipo,
|
||||
|
|
|
|||
Loading…
Reference in New Issue