backend
backend copied to clipboard
Improve email generation logic
As mentioned in #1031, I really think #932 is the wrong approach to generate the emails:
all_submissions_by_grader_for_index
generates a view (JSON string), which is then converted back to a "model" using Jason.decode
, which is then further manipulated, and the final view is generated using the email template.
This results in a lot of coupling, especially across the various layers of the backend, which means PRs like #1031 are unnecessarily breaking.
My proposal would be to create a separate function entirely for this functionality, which would optimise everything as well.
I feel the ideal way would simply be to create a function all_ungraded_submissions_by_grader
which has a much more optimised SQL query to only return the necessary fields for the email (especially since the second argument to all_ungraded_submissions_by_grader
is always true for emails)