Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
81e8ed7a
Commit
81e8ed7a
authored
4 years ago
by
Justus Dieckmann
Browse files
Options
Downloads
Patches
Plain Diff
Restructure Delay-SQL-Query to avoid full joins which are not supported by mysql
parent
7cfd0895
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
classes/local/table/delayed_courses_table.php
+21
-14
21 additions, 14 deletions
classes/local/table/delayed_courses_table.php
with
21 additions
and
14 deletions
classes/local/table/delayed_courses_table.php
+
21
−
14
View file @
81e8ed7a
...
...
@@ -67,25 +67,31 @@ class delayed_courses_table extends \table_sql {
}
if
(
$selectseperatedelays
)
{
$fields
.
=
'
d
w.workflowid, w
.title as
workflow,
dw.
delay
eduntil AS
workflowdelay,
maxtable.wfcount AS
workflowcount, '
;
$fields
.
=
'w
fdelay
.workflowid, w
fdelay.
workflow,
wf
delay
.
workflowdelay,
wfdelay.
workflowcount, '
;
}
else
{
$fields
.
=
'null as workflowid, null as workflow, null AS workflowdelay, null AS workflowcount, '
;
}
$params
=
[];
if
(
$selectglobaldelays
)
{
$fields
.
=
'd.delayeduntil AS globaldelay'
;
}
else
{
$fields
.
=
'null AS globaldelay'
;
}
$params
=
[];
$where
=
[
"TRUE"
];
if
(
$selectglobaldelays
&&
!
$selectseperatedelays
)
{
$from
=
'{tool_lifecycle_delayed} d '
.
'JOIN {course} c ON c.id = d.courseid '
.
'JOIN {course_categories} cat ON c.category = cat.id'
;
}
else
{
$from
=
'('
.
$from
=
'{course} c '
.
// For every course, add information about delays per workflow.
'LEFT JOIN ('
.
'SELECT dw.courseid, dw.workflowid, w.title as workflow, '
.
'dw.delayeduntil as workflowdelay,maxtable.wfcount as workflowcount '
.
'FROM ( '
.
'SELECT courseid, MAX(dw.id) AS maxid, COUNT(*) AS wfcount '
.
'FROM {tool_lifecycle_delayed_workf} dw '
.
'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id '
.
// To make sure no outdated delays are counted.
...
...
@@ -101,35 +107,36 @@ class delayed_courses_table extends \table_sql {
$from
.
=
'GROUP BY courseid '
.
') maxtable '
.
'JOIN {tool_lifecycle_delayed_workf} dw ON maxtable.maxid = dw.id '
.
'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id '
;
'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id '
.
') wfdelay ON wfdelay.courseid = c.id '
;
if
(
$selectglobaldelays
)
{
$from
.
=
'FULL JOIN ('
.
// For every course, add information about global delay.
$from
.
=
'LEFT JOIN ('
.
'SELECT * FROM {tool_lifecycle_delayed} d '
.
'WHERE d.delayeduntil > :time2 '
.
') d ON dw.courseid = d.courseid '
.
'JOIN {course} c ON c.id = COALESCE(dw.courseid, d.courseid) '
;
') d ON c.id = d.courseid '
;
$params
[
'time2'
]
=
time
();
// Only include course in resultset, if it has a delay of some kind (global or per wf).
$where
[]
=
'COALESCE(wfdelay.courseid, d.courseid) IS NOT NULL'
;
}
else
{
$
from
.
=
'JOIN {course} c ON c.id = dw.courseid
'
;
$
where
[]
=
'wfdelay.courseid IS NOT NULL
'
;
}
$from
.
=
'JOIN {course_categories} cat ON c.category = cat.id'
;
}
$where
=
'true '
;
if
(
$filterdata
&&
$filterdata
->
category
)
{
$where
.
=
'AND
cat.id = :catid '
;
$where
[]
=
'
cat.id = :catid '
;
$params
[
'catid'
]
=
$filterdata
->
category
;
}
if
(
$filterdata
&&
$filterdata
->
coursename
)
{
global
$DB
;
$where
.
=
'AND
c.fullname LIKE :cname'
;
$where
[]
=
'
c.fullname LIKE :cname'
;
$params
[
'cname'
]
=
'%'
.
$DB
->
sql_like_escape
(
$filterdata
->
coursename
)
.
'%'
;
}
$where
=
join
(
" AND "
,
$where
);
$this
->
set_sql
(
$fields
,
$from
,
$where
,
$params
);
$this
->
column_nosort
=
[
'workflow'
,
'tools'
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment