Query optimizado sin función de fechas_clase.
This commit is contained in:
@@ -32,8 +32,8 @@ try {
|
|||||||
// Define relevant columns
|
// Define relevant columns
|
||||||
$relevant_columns = [
|
$relevant_columns = [
|
||||||
'registro_id',
|
'registro_id',
|
||||||
'fechas.registro_fecha_ideal',
|
'fechas.fecha as registro_fecha_ideal',
|
||||||
'fechas.horario_id',
|
'horario.horario_id',
|
||||||
'profesor.profesor_id',
|
'profesor.profesor_id',
|
||||||
'salon',
|
'salon',
|
||||||
'profesor_clave',
|
'profesor_clave',
|
||||||
@@ -85,7 +85,7 @@ try {
|
|||||||
"SELECT horario_id FROM horario
|
"SELECT horario_id FROM horario
|
||||||
WHERE horario_dia IN ($DaysWeek)
|
WHERE horario_dia IN ($DaysWeek)
|
||||||
AND periodo_id IN ($PeriodosHorarios)
|
AND periodo_id IN ($PeriodosHorarios)
|
||||||
AND :fecha_inicio BETWEEN horario_fecha_inicio AND COALESCE(horario_fecha_fin, :fecha_fin)
|
AND (:fecha_inicio, :fecha_fin) OVERLAPS (horario_fecha_inicio, COALESCE(horario_fecha_fin, :fecha_fin))
|
||||||
AND facultad_id = COALESCE(:facultad_id, facultad_id)",
|
AND facultad_id = COALESCE(:facultad_id, facultad_id)",
|
||||||
array_merge($fechas, [
|
array_merge($fechas, [
|
||||||
':facultad_id' => $user->facultad['facultad_id'],
|
':facultad_id' => $user->facultad['facultad_id'],
|
||||||
@@ -95,15 +95,7 @@ try {
|
|||||||
|
|
||||||
$Horarios = $db->query(
|
$Horarios = $db->query(
|
||||||
"WITH fechas AS (
|
"WITH fechas AS (
|
||||||
SELECT fechas_clase(
|
SELECT generate_series(:fecha_inicio, :fecha_fin, '1 day'::INTERVAL)::DATE AS fecha
|
||||||
_horario_id => h.horario_id,
|
|
||||||
_todos => false,
|
|
||||||
_fecha_inicio => :fecha_inicio,
|
|
||||||
_fecha_fin => :fecha_fin
|
|
||||||
) AS registro_fecha_ideal, h.horario_id, profesor_id
|
|
||||||
FROM horario h
|
|
||||||
JOIN horario_profesor USING (horario_id)
|
|
||||||
WHERE horario_id IN ($HorariosID)
|
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
$RelevantColumns,
|
$RelevantColumns,
|
||||||
@@ -112,16 +104,18 @@ try {
|
|||||||
ELSE 'primary'
|
ELSE 'primary'
|
||||||
END AS color
|
END AS color
|
||||||
FROM horario
|
FROM horario
|
||||||
JOIN fechas USING (horario_id)
|
JOIN horario_profesor USING (horario_id)
|
||||||
|
JOIN fechas ON EXTRACT(DOW FROM fechas.fecha) = horario.horario_dia
|
||||||
JOIN profesor USING (profesor_id)
|
JOIN profesor USING (profesor_id)
|
||||||
JOIN salon USING (salon_id)
|
JOIN salon USING (salon_id)
|
||||||
LEFT JOIN REGISTRO ON
|
LEFT JOIN REGISTRO ON
|
||||||
REGISTRO.profesor_id = PROFESOR.profesor_id AND
|
REGISTRO.profesor_id = horario_profesor.profesor_id AND
|
||||||
REGISTRO.horario_id = FECHAS.horario_id AND
|
REGISTRO.horario_id = horario.horario_id AND
|
||||||
FECHAS.registro_fecha_ideal = REGISTRO.registro_fecha_ideal
|
REGISTRO.registro_fecha_ideal = fechas.fecha
|
||||||
LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id
|
LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id
|
||||||
JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(REGISTRO.estado_supervisor_id, 0)
|
JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(REGISTRO.estado_supervisor_id, 0)
|
||||||
ORDER BY fechas.registro_fecha_ideal, horario_hora",
|
WHERE horario.horario_id IN ($HorariosID)
|
||||||
|
ORDER BY fechas.fecha, horario_hora",
|
||||||
$fechas
|
$fechas
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -347,25 +347,44 @@
|
|||||||
<!-- page -->
|
<!-- page -->
|
||||||
<nav v-if="store.registros.relevant.length > 0" class="mt-3 col-12">
|
<nav v-if="store.registros.relevant.length > 0" class="mt-3 col-12">
|
||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
|
<!-- Botón para ir a la primera página -->
|
||||||
|
<li class="page-item" :class="{'disabled': store.current.page == 1}" @click="store.current.page = 1"
|
||||||
|
:disabled="store.current.page == 1" :title="`Ir a la primera página`">
|
||||||
|
<a class="page-link" style="cursor: pointer;">Primera</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<!-- Botón Anterior -->
|
||||||
<li class="page-item" :class="{'disabled': store.current.page == 1}"
|
<li class="page-item" :class="{'disabled': store.current.page == 1}"
|
||||||
@click="store.current.page == 1 ? '' : store.current.page--" :disabled="store.current.page == 1"
|
@click="store.current.page == 1 ? '' : store.current.page--" :disabled="store.current.page == 1"
|
||||||
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
||||||
<a class="page-link" style="cursor: pointer;">Anterior</a>
|
<a class="page-link" style="cursor: pointer;">Anterior</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<!-- Páginas dinámicas -->
|
||||||
<li class="page-item"
|
<li class="page-item"
|
||||||
v-for="page in [...Array(store.registros.pages).keys()].map(x => ++x).slice(store.current.page - 3 > 0 ? store.current.page - 3 : 0, store.current.page + 2 < store.registros.pages ? store.current.page + 2 : store.registros.pages)"
|
v-for="page in [...Array(store.registros.pages).keys()].map(x => ++x).slice(store.current.page - 3 > 0 ? store.current.page - 3 : 0, store.current.page + 2 < store.registros.pages ? store.current.page + 2 : store.registros.pages)"
|
||||||
:class="{'active': store.current.page == page}" @click="store.current.page = page"
|
:class="{'active': store.current.page == page}" @click="store.current.page = page"
|
||||||
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
||||||
<a class="page-link" style="cursor: pointer;">{{ page }}</a>
|
<a class="page-link" style="cursor: pointer;">{{ page }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<!-- Botón Siguiente -->
|
||||||
<li class="page-item" :class="{'disabled': store.current.page == store.registros.pages}"
|
<li class="page-item" :class="{'disabled': store.current.page == store.registros.pages}"
|
||||||
:disabled="store.current.page == store.registros.pages"
|
:disabled="store.current.page == store.registros.pages"
|
||||||
@click="store.current.page += store.current.page == store.registros.pages ? 0 : 1"
|
@click="store.current.page += store.current.page == store.registros.pages ? 0 : 1"
|
||||||
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
:title="`Página ${store.current.page} de ${store.registros.pages}`">
|
||||||
<a class="page-link" style="cursor: pointer;">Siguiente</a>
|
<a class="page-link" style="cursor: pointer;">Siguiente</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<!-- Botón para ir a la última página -->
|
||||||
|
<li class="page-item" :class="{'disabled': store.current.page == store.registros.pages}"
|
||||||
|
@click="store.current.page = store.registros.pages"
|
||||||
|
:disabled="store.current.page == store.registros.pages" :title="`Ir a la última página`">
|
||||||
|
<a class="page-link" style="cursor: pointer;">Última</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,22 +22,16 @@ $profesor_clave = isset($params['profesor'])
|
|||||||
|
|
||||||
$data = $db->query(
|
$data = $db->query(
|
||||||
"WITH fechas AS (
|
"WITH fechas AS (
|
||||||
SELECT fechas_clase(
|
SELECT generate_series(:fecha_inicio, :fecha_fin, '1 day'::INTERVAL)::DATE AS registro_fecha_ideal
|
||||||
_horario_id => h.horario_id,
|
|
||||||
_todos => false,
|
|
||||||
_fecha_inicio => :fecha_inicio,
|
|
||||||
_fecha_fin => :fecha_fin
|
|
||||||
) AS registro_fecha_ideal, h.horario_id
|
|
||||||
FROM horario h WHERE horario_id IN ({$_SESSION['horarios']})
|
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
fechas.registro_fecha_ideal,
|
fechas.registro_fecha_ideal,
|
||||||
profesor_clave,
|
profesor_clave,
|
||||||
profesor_nombre,
|
COALESCE(materia_asignacion.materia_asignacion_profesor, profesor.profesor_nombre) AS profesor_nombre,
|
||||||
profesor_correo,
|
profesor_correo,
|
||||||
facultad_nombre,
|
facultad_nombre,
|
||||||
materia_nombre,
|
COALESCE(materia_asignacion.materia_asignacion_materia, materia.materia_nombre) AS materia_nombre,
|
||||||
carrera_nombre,
|
COALESCE(materia_asignacion.materia_asignacion_carrera, carrera.carrera_nombre) AS carrera_nombre,
|
||||||
horario_grupo,
|
horario_grupo,
|
||||||
horario_hora,
|
horario_hora,
|
||||||
horario_fin,
|
horario_fin,
|
||||||
@@ -52,14 +46,16 @@ $data = $db->query(
|
|||||||
comentario,
|
comentario,
|
||||||
justificacion
|
justificacion
|
||||||
FROM horario
|
FROM horario
|
||||||
NATURAL JOIN fechas
|
|
||||||
NATURAL JOIN horario_profesor
|
NATURAL JOIN horario_profesor
|
||||||
NATURAL JOIN profesor
|
NATURAL JOIN profesor
|
||||||
|
JOIN fechas ON EXTRACT(DOW FROM fechas.registro_fecha_ideal) = horario_dia
|
||||||
NATURAL JOIN salon_view_mat
|
NATURAL JOIN salon_view_mat
|
||||||
|
|
||||||
NATURAL JOIN facultad
|
JOIN facultad ON facultad.facultad_id = COALESCE(horario.facultad_id, 0)
|
||||||
NATURAL JOIN materia
|
LEFT JOIN materia USING (MATERIA_ID)
|
||||||
NATURAL JOIN carrera
|
LEFT JOIN carrera USING (carrera_id)
|
||||||
|
|
||||||
|
LEFT JOIN materia_asignacion USING (horario_id)
|
||||||
|
|
||||||
LEFT JOIN REGISTRO USING (profesor_id, registro_fecha_ideal, horario_id)
|
LEFT JOIN REGISTRO USING (profesor_id, registro_fecha_ideal, horario_id)
|
||||||
LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id
|
LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id
|
||||||
@@ -70,6 +66,7 @@ $data = $db->query(
|
|||||||
(horario_hora, horario_fin)
|
(horario_hora, horario_fin)
|
||||||
OVERLAPS
|
OVERLAPS
|
||||||
(COALESCE(:bloque_inicio, horario_hora), COALESCE(:bloque_fin, horario_fin))
|
(COALESCE(:bloque_inicio, horario_hora), COALESCE(:bloque_fin, horario_fin))
|
||||||
|
AND horario_id IN ({$_SESSION['horarios']})
|
||||||
ORDER BY fechas.registro_fecha_ideal, horario_hora",
|
ORDER BY fechas.registro_fecha_ideal, horario_hora",
|
||||||
[
|
[
|
||||||
'facultad_id' => $user->facultad['facultad_id'] ?? $params['facultad_id'],
|
'facultad_id' => $user->facultad['facultad_id'] ?? $params['facultad_id'],
|
||||||
|
|||||||
Reference in New Issue
Block a user