fix cross-shard todo lists
fixes CNVS-30216 test plan: * enroll a user into a course on another shard * add an assignment to that course, due within the next week * masquerade as the out-of-shard student * go to the course home page * it should show the assignment in the todo list on the top right Change-Id: I5fdc8fb0eba4b4d4826272450521dc7765ce3203 Reviewed-on: https://gerrit.instructure.com/86838 Tested-by: Jenkins Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
b4c4ef93d1
commit
b2d203bf4b
|
@ -1483,7 +1483,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
courses = Course.find(options[:shard_course_ids])
|
||||
assignments = assignment_scope.
|
||||
filter_by_visibilities_in_given_courses(self.id, courses.map(&:id)).
|
||||
filter_by_visibilities_in_given_courses(id, courses.map(&:id)).
|
||||
published.
|
||||
due_between_with_overrides(due_after, due_before).
|
||||
expecting_submission.
|
||||
|
@ -1999,10 +1999,12 @@ class User < ActiveRecord::Base
|
|||
|
||||
def select_available_assignments(assignments)
|
||||
return [] if assignments.empty?
|
||||
enrollments = self.enrollments.where(:course_id => assignments.select{|a| a.context_type == "Course"}.map(&:context_id)).to_a
|
||||
enrollments = Shard.partition_by_shard(assignments.map(&:context_id)) do |course_ids|
|
||||
self.enrollments.shard(Shard.current).where(course_id: course_ids).to_a
|
||||
end
|
||||
Canvas::Builders::EnrollmentDateBuilder.preload_state(enrollments)
|
||||
enrollments.select!{|e| e.participating?}
|
||||
assignments.select{|a| a.context_type != "Course" || enrollments.any?{|e| e.course_id == a.context_id}}
|
||||
enrollments.select! {|e| e.participating? }
|
||||
assignments.select {|a| enrollments.any? {|e| e.course_id == a.context_id} }
|
||||
end
|
||||
|
||||
def select_upcoming_assignments(assignments,opts)
|
||||
|
|
|
@ -1976,6 +1976,16 @@ describe User do
|
|||
expect(@student.assignments_needing_submitting(contexts: Course.all).include?(assignment)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "sharding" do
|
||||
specs_require_sharding
|
||||
|
||||
it "includes assignments from other shards" do
|
||||
student = @shard1.activate { user }
|
||||
assignment = create_course_with_assignment_needing_submitting(student: student, override: true)
|
||||
expect(student.assignments_needing_submitting).to eq [assignment]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "submissions_needing_peer_review" do
|
||||
|
|
Loading…
Reference in New Issue