-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement to the speed of the emailing certificate task (#531) #610
Improvement to the speed of the emailing certificate task (#531) #610
Conversation
@mohamedmohamedatia can we not use the Other notes -
I think the concept is good, doing the emailing in batches but I think we can use the existing table to do this. I am still unsure about the other settings. The other big flaw with this approach if I am correct is that we rely on a count which is not a good indicator. If we run the task and we process 50 users, then we unenrol them all and enrol 50 new users these new users will not be emailed as we are storing 50. Correct me if I am wrong. Thanks, look forward to your reply. |
Apologies for the delay in responding. I missed reading the notification email and just noticed it now. Thank you for your valuable feedback. I'll review and implement your suggestions promptly and will reply soon. Best regards, |
@mdjnelson Before my edits, the task was indeed handling two primary functions: issuing certificates and sending emails. It loops through all certificates on the system to check if new users could issue them. I introduced a new feature that allows administrators to determine how many certificates to process during each run. By default, if set to 0, it will check all certificates. I introduced a table to store the starting position for certificate processing each run. For example, if there are 1000 certificates and the admin sets 100 certificates per run, after the first run, it stores 100 as the last_processed field. Subsequent runs begin from position 101, I am not sure if the task_log table alone can achieve this, I will wait for further direction from your side if there is a better way to store the start position. Regarding Other notes – I created a branch named Notes#610 and all notes are done; should I merge now? Regarding your concern about the count, it's for looping over certificates, not users. It determines the batch size for processing certificates, not users for issuance, as highlighted above. Regarding users, instead of iterating over all enrolled users, the loop now targets users with the capability "issue certificate". Additionally, I added the ability for admins to exclude certificates from hidden courses and categories, vital in our university where old terms are often hidden. This ensures active term certificates are only processed by default, with the option to include hidden courses if needed. Also, admins can exclude old courses that ended in the past over a determined period from processing. Thanks, look forward to your reply. |
@mohamedmohamedatia you can just add a commit onto the same branch instead of creating a new pull request or branch and I can see them here. I'll address the rest of this review when I am next working on the project. |
Apply notes from @mdjnelson mdjnelson#610
Thanks @mohamedmohamedatia. Can you squash these commits into one and rebase this on the latest version of MOODLE_402_STABLE. Right now there are conflicts. Thanks! |
5e140c1
to
3172f46
Compare
Hi Mark, It was my first time squashing commits, but I followed online tutorials to ensure I did it correctly. As a result, we now have two succinct commits:
Please let me know if there's anything else I can assist you with. |
Hi @mohamedmohamedatia, did you pull down the latest updates of the customcert version 4.2 and then do the rebase as I still get the errorr "This branch has conflicts that must be resolved" on GitHub? Also these aren't exactly succinct since the second commit contains fixes for the first commit. I would prefer them separated, or just have one commit (easiest solution). |
2fe9ffb
to
3172f46
Compare
@mohamedmohamedatia, there are still conflicts. You will need to |
b31cc81
to
cab71d5
Compare
Hi Mark, |
Awesome work @mohamedmohamedatia. When I get time ill give it another review. :) |
Hi @mohamedmohamedatia can you fix this issues raised by the automated tests? :) |
Hi Mark, Noted, will address them soon. |
11196d1
to
10aa843
Compare
Hi Mark, |
10aa843
to
969784b
Compare
Thanks @mohamedmohamedatia, I am currently busy with work outside of Moodle but when I get a chance ill give it an extensive review. Regards, Mark |
Looking at this now. Just going to comment that this will solve #531 so it links in GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @mohamedmohamedatia and your perseverance.
I have made several comments in the diff.
Also, the git commit message should not be so long.
I suggest -
Optimise email certificate task. (#531)
By reducing database reads/writes and introducing
configurable settings for task efficiency.
Also the version in version.php
needs to be 2023042409
. I will sort this out when I backport it to version 4.1 as it will need a different version so don't worry about that.
I don't want to step on any toes, but I (or someone on my team) could review this, and update code with Mark's suggestions if @mohamedmohamedatia won't have time soon to work on this. We have several clients that have been having performance problems with this. |
Go ahead Eric. Thanks! :) |
Hi @mdjnelson, I'm Oscar I work for Moodle US and I working on this, so I went deep into this issue and I think we have 2 pain points here.
|
Let me look at this properly tomorrow. I appreciate you taking your time to work on this and contribute. No harm in doing a PR now so we can start a discussion there. |
I also noticed from this fork https://github.com/Claud10R/moodle-mod_customcert that @Claud10R created some commits to work on this. Would be good to see if perhaps we can make this even more efficient. Waiting on PR before reviewing. :) |
Hi, awesome I'll review it CLaud's commits. |
969784b
to
8f77308
Compare
By reducing database reads/writes and introducing configurable settings for task efficiency.
4950be3
to
826dc8d
Compare
Hi Mark, I apologize for the delay in my response. I was on an extended leave for two months and was unable to review emails during that period. I have reviewed your comments and made the necessary changes. I’ve also added my responses to each of your comments. Please note that while I haven’t completely halted the processing of hidden courses, I’ve enabled administrators to make a selection based on their operational policies. The default setting will not process hidden courses. The default configuration now processes courses with an end date no older than one year. However, administrators can adjust this setting to zero if they wish to include all courses. Courses without an end date are considered open and will always be processed, such as self-study courses. I will review #632 at a later time, but I suggest we proceed with #610 for now and consider #632 as future enhancements. Please let me know if you have any suggestions for alternative scenarios. Best regards, |
Ignore the failures for now as it seems to be because of moodlehq/moodle-plugin-ci#309. |
No worries, I’ll ignore the failures for now since it seems to be related to moodlehq/moodle-plugin-ci#309. I ran the tests on my side, and everything passed just fine! |
I have cherry-picked this (with some minor changes) in to 4.4, 4.3, 4.2 and 4.1. I have not released it as a version in the plugins DB though. @mohamedmohamedatia just to confirm that if this processes a particular course that it does not ignore it when it does the batching? New students could still qualify for the certificate after its been processed. |
Hi Mark
Great news, Thank you for cherry-picking the changes into the different versions!, I can confirm that after a course is processed, it is not excluded in future batches. This ensures that any new students who meet the criteria after the initial processing will still qualify for the certificate.
|
Awesome, closing. :) Thanks @mohamedmohamedatia for all your hard work, it's appreciated. |
Thanks @mdjnelson ! It’s been great working on this plugin. I appreciate the chance to contribute! |
Hi @mohamedmohamedatia, it seems this introduced an urgent bug that needs fixing. Can you take a look at https://moodle.org/mod/forum/discuss.php?d=461260 and see if you can spot the issue? |
The following code was removed -
|
I created a fix you can find at 94cfd4b. I am not sure why |
No description provided.