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