From 501eabc19313377919a563f8e8e0a5eeb6c8bc17 Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Fri, 21 Jun 2019 17:05:40 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20e=20otimiza=C3=A7=C3=A3o?= =?UTF-8?q?=20em=20query=20de=20sincroniza=C3=A7=C3=A3o=20de=20cursos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/task/escola_modelo.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/classes/task/escola_modelo.php b/classes/task/escola_modelo.php index f8a26ef..ef9062f 100644 --- a/classes/task/escola_modelo.php +++ b/classes/task/escola_modelo.php @@ -84,22 +84,20 @@ class escola_modelo extends \core\task\scheduled_task { $sqlCourses = ' SELECT c.*, d.value as ind_publico_evl FROM {course} c - LEFT JOIN {ilb_sync_course} sc - ON c.id = sc.course_id JOIN {context} ctx - ON c.id = ? - AND ctx.contextlevel = 50 + ON ctx.contextlevel = 50 AND ctx.instanceid = c.id JOIN {customfield_field} f ON f.shortname = ? - JOIN {customfield_data} d + LEFT JOIN {customfield_data} d ON d.fieldid = f.id - AND d.contextid = ctx.id + AND d.contextid = ctx.id + LEFT JOIN {ilb_sync_course} sc + ON c.id = sc.course_id WHERE (sc.course_id is null - OR c.timemodified > sc.time_sync) - '; + OR c.timemodified > sc.time_sync) '; - $listaCursos = $DB->get_records_sql($sqlCourses,array()); + $listaCursos = $DB->get_records_sql($sqlCourses,array(CURSO_CUSTOMFIELD_PUBLICO)); // Atualiza cada um dos cursos pendentes foreach($listaCursos as $curso) {