Refactor a method so the Assignments#show action is faster
Refactor a method so the Assignments#show action is faster

In AssignmentsController#show we call@assignment.ensure_assignment_group
which was causing this to be called and also causing a:
SELECT "assignment_groups".* 
FROM "assignment_groups" 
WHERE "assignment_groups"."context_id" = 1 
	AND "assignment_groups"."context_type" = 'Course' 
	AND (assignment_groups.workflow_state<>'deleted') 
ORDER BY assignment_groups.position, 
    CAST(LOWER(replace(assignment_groups.name, '\', '\\')) AS bytea)

…even if the assignment already had an assignment_group_id

We should be able to avoid doing that query if we already have an
assignment_group_id

Test plan:
* for an assignment that already has an assignment_grou_id
* go to AssignmentsController#show (with or without a2 on)
* it should not run that ^ query

Change-Id: I64d1d845c50a4cf3e56d2b750954c5a8a778c265
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218101
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Tested-by: Jenkins
Reviewed-by: Steven Burnett <a0b450117c5d20a22d5c4d52bb8ae13adee003d8@instructure.com>
QA-Review: Ryan Shaw <ea3cd978650417470535f3a4725b6b5042a6ab59@instructure.com>
Product-Review: Ryan Shaw <ea3cd978650417470535f3a4725b6b5042a6ab59@instructure.com>

sfu/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,djbender/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,djbender/canvas-lms,sfu/canvas-lms,djbender/canvas-lms,sfu/canvas-lms,instructure/canvas-lms,sfu/canvas-lms,djbender/canvas-lms,instructure/canvas-lms,sfu/canvas-lms