Closed golenkovm closed 2 years ago
Please find profiling for the request below:
It shows how the number of calls jumps from 9 prepare_dashboard_content()
up to 5k for_block_instance()
.
A side note: some blocks have Display on page types
set to Any page
, so they are picked up by $OUTPUT->blocks('side-pre');
and there fore there is a call to get_content()
.
Thanks for the profiling trace. I've revised the site/non-site-page test to use page context level instead of taking guesses from page type values, which hindsight says I probably should have done when I changed it 11 months ago. The way I'm sniffing CLI/PHPUnit gives me uneasiness, so I'm going to mull on that a little more. We may also be able to optimise away entirely a wasted block render with this:
--- a/block_completion_progress.php
+++ b/block_completion_progress.php
@@ -117,6 +117,9 @@ class block_completion_progress extends block_base {
return $this->content;
}
+ if (AJAX_SCRIPT) {
+ return $this->content;
+ }
if (self::on_site_page($this->page)) {
// Draw the multi-bar content for the Dashboard and Front page.
if (!$this->prepare_dashboard_content($barinstances)) {
Thank you @jonof I haven't tested your patch yet, but the code looks good. Cheers
Hi @jonof I just deployed the recent code and gave this a test. It seems like the patch works as expected and the issue if fully fixed. Thank you.
Hi,
In a Moodle 3.9 site with 8,000 Completions progress block instances teachers can't open assignment grading page. The
/lib/ajax/service.php?sesskey=xxx&info=core_get_fragment'
AJAX call takes ages to complete.As I can see
on_site_page()
returnstrue
https://github.com/jonof/moodle-block_completion_progress/blob/0772069a24b132ac585f7b98706edef6d0a0a62c/block_completion_progress.php#L333 because$page->pagetype
is set tosite-index
for this call. Thus,get_content()
iterates through all teacher's courses and then through all course blocks.