Fixed create vote mutation
This commit is contained in:
parent
4f11106e74
commit
79c73ee57a
|
@ -109,25 +109,11 @@ module MW
|
|||
|
||||
@[GraphQL::Field]
|
||||
def create_vote(context : Context, input : VoteCreateInput) : Vote
|
||||
# context.admin!
|
||||
|
||||
# student = Db::Student.find!(input.student_id)
|
||||
# # student.vote = Db::Vote.new(student_id: student.id)
|
||||
# # student.save!
|
||||
# pp! Db::Vote.create!(student_id: student.id.not_nil!)
|
||||
# pp! student
|
||||
# pp! student.vote
|
||||
# input.teacher_ids.not_nil!.each_with_index do |t_id, i|
|
||||
# Db::TeacherVote.create!(vote_id: student.vote.not_nil!.id.not_nil!, teacher_id: t_id, priority: i)
|
||||
# end if input.teacher_ids
|
||||
# pp! student.vote.not_nil!.teacher_votes.to_a
|
||||
|
||||
# Vote.new(student.vote.not_nil!)
|
||||
|
||||
context.role! UserRole::Student
|
||||
|
||||
student = context.external.not_nil!.as(Db::Student)
|
||||
vote = Db::Vote.create!(student_id: student.id)
|
||||
Db::TeacherVote.import(input.teacher_ids.map_with_index { |id, i| Db::TeacherVote.new(vote_id: vote.id, teacher_id: id.to_i64, priority: i) })
|
||||
|
||||
Vote.new(vote)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue