mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Some improvements in efficiency of Recent Activity.
There is now a new field in forum_discussions which has the userid of the author in it. This saves a lookup every time to forum_posts. There is also some caching and rearrangement of the logic. It seems to work OK, I'm about to do some speed tests on moodle.org
This commit is contained in:
parent
da8079852c
commit
d05956ac9f
8 changed files with 80 additions and 19 deletions
|
@ -83,6 +83,19 @@ function forum_upgrade($oldversion) {
|
|||
if ($oldversion < 2004010100) {
|
||||
table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004011404) {
|
||||
table_column("forum_discussions", "", "userid", "integer", "10", "unsigned", "0", "", "firstpost");
|
||||
|
||||
if ($discussions = get_records_sql("SELECT d.id, p.userid
|
||||
FROM {$CFG->prefix}forum_discussions as d,
|
||||
{$CFG->prefix}forum_posts as p
|
||||
WHERE d.firstpost = p.id")) {
|
||||
foreach ($discussions as $discussion) {
|
||||
update_record("forum_discussions", $discussion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ CREATE TABLE prefix_forum_discussions (
|
|||
forum int(10) unsigned NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
firstpost int(10) unsigned NOT NULL default '0',
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
assessed tinyint(1) NOT NULL default '1',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id)
|
||||
|
|
|
@ -27,11 +27,23 @@ function forum_upgrade($oldversion) {
|
|||
table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004011404) {
|
||||
table_column("forum_discussions", "", "userid", "integer", "10", "unsigned", "0", "", "firstpost");
|
||||
|
||||
if ($discussions = get_records_sql("SELECT d.id, p.userid
|
||||
FROM {$CFG->prefix}forum_discussions as d,
|
||||
{$CFG->prefix}forum_posts as p
|
||||
WHERE d.firstpost = p.id")) {
|
||||
foreach ($discussions as $discussion) {
|
||||
update_record("forum_discussions", $discussion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ CREATE TABLE prefix_forum_discussions (
|
|||
forum integer NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
firstpost integer NOT NULL default '0',
|
||||
userid integer NOT NULL default '0',
|
||||
assessed integer NOT NULL default '1',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue