Unread-functionality requires the "upgradeforumread.php" to be completed?

Unread-functionality requires the "upgradeforumread.php" to be completed?

by Samuli Karevaara -
Number of replies: 3
As the post title says. The script upgradeforumread.php runs for quite a while smile

The counter seems to go mad though, it imncrements per post, but the totals are for discussions. This might be due to the use of "static $count" in function print_progress().

I might have misunderstood something though: the print_progress is called inside the "posts" loop, but the page says "Upgrading x discussions ... y done" and y goes wild? smile

I have to take a look at this script, there has to be something to be done about the speed (overusing smileys here) smile
Average of ratings: -
In reply to Samuli Karevaara

Re: Unread-functionality requires the "upgradeforumread.php" to be completed?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
At the start we don't actually know how many posts we need to process, which is why it just tells you about discussions at the start and keeps you updated with info about the updates it's done. Overall the progress bar works fine for me on my upgrades.

It's actually faster then it used to be (when I tried upgrading moodle.org) ... I couldn't see any way to speed it up further but I hope you can!! big grin
In reply to Martin Dougiamas

Re: Unread-functionality requires the "upgradeforumread.php" to be completed?

by Samuli Karevaara -
I take this as a "yes" to my question in the post title? smile

Just quite confusing to see "Upgrading 540 discussions ... 8545 done", the bar itself seems to work, but the counter number should reflect the discussions or say something about the posts. Not a biggie, as this is an admin feature only.

Speeding it up might require combining the sql queries, but it's difficult if not impossible using the update_record and an object. Maybe a spiced up update_record to accept an array of records, the combining them into a single sql query? I might be onto something here smile Another thing is that the script seems to go through a lot of unnecessary posts, just have to specify a way to seed them out early on...

Edit: thanks for a speedy answer btw!
In reply to Martin Dougiamas

Re: Unread-functionality requires the "upgradeforumread.php" to be completed?

by Samuli Karevaara -
I took a look at the script, and didn't see an obvious way to simplify the complexity (Big-O-wise) of the script.

The biggest slowdown is that it inserts the rows one by one. MySQL supports (since 3.23.something) inserting multiple rows at a time, but I don't know if this is in any standard INSERT or supported by adodb, so... Also, it would require some tweaking at the current insert_record function. I've used the "batch insert" in MySQL with massive insert operations, and the speedup is significant (several times faster), but this might be a MySQL-only thing.

Some things I tried anyway:

One thing to do is to only get the users for the course that have logged on since the $dateafter and leave the posts as unread for those who we haven't seen in a while.

The script can ignore the "old post?" test as we did it in the script while getting the discussions.

For fresh updates the "read" table is empty when the script starts, so the check for "insert or upgrade?" can be ignored and go straight to the insert bit.

But at the end of the day, I left it as it was, as it's just a one time thing and the speed is not as important as that it's not a hacked mess...