backend icon indicating copy to clipboard operation
backend copied to clipboard

Improve email generation logic

Open RichDom2185 opened this issue 1 year ago • 1 comments

As mentioned in #1031, I really think #932 is the wrong approach to generate the emails:

image

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.

RichDom2185 avatar Nov 06 '23 21:11 RichDom2185

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)

RichDom2185 avatar Nov 06 '23 21:11 RichDom2185