add: schedule db

This commit is contained in:
Muhammad Afif
2025-10-11 12:16:24 +07:00
parent 988bcaf301
commit 47051766e3

View File

@@ -31,7 +31,7 @@ const getAllScheduleDb = async (searchParams = {}) => {
c.shift_id
FROM schedule a
LEFT JOIN m_shift b ON a.shift_id = b.shift_id
LEFT JOIN user_schedule c ON a.user_schedule_id = c.user_schedule_id
LEFT JOIN user_schedule c ON a.schedule_id = c.user_schedule_id
WHERE a.deleted_at IS NULL
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}
${whereOrConditions ? ` ${whereOrConditions}` : ""}
@@ -59,7 +59,6 @@ const getAllScheduleDb = async (searchParams = {}) => {
const getScheduleByIdDb = async (id) => {
const queryText = `
SELECT
COUNT(*) OVER() AS total_data,
a.*,
b.shift_id,
b.shift_name,
@@ -69,7 +68,7 @@ const getScheduleByIdDb = async (id) => {
c.user_id
FROM schedule a
LEFT JOIN m_shift b ON a.shift_id = b.shift_id
LEFT JOIN user_schedule c ON a.user_schedule_id = c.user_schedule_id
LEFT JOIN user_schedule c ON a.schedule_id = c.user_schedule_id
WHERE a.schedule_id = $1 AND a.deleted_at IS NULL
`;
const result = await pool.query(queryText, [id]);