@@ -99,13 +99,19 @@ defmodule CF.Graphql.Resolvers.Comments do
9999 end
100100 end
101101
102- def flag ( _root , % { comment_id: comment_id , reason: reason } , % { context: % { user: user } } ) do
102+ def flag ( _root , % { comment_id: comment_id_str , reason: reason } , % { context: % { user: user } } ) do
103103 # Get comment and preload statement to access video_id
104- comment = Repo . get! ( Comment , comment_id ) |> Repo . preload ( :statement )
105- video_id = comment . statement . video_id
106-
104+ comment_id = String . to_integer ( comment_id_str )
105+ video_id =
106+ Comment
107+ |> join ( :inner , [ c ] , s in assoc ( c , :statement ) )
108+ |> select ( [ c , s ] , s . video_id )
109+ |> where ( [ c , s ] , c . id == ^ comment_id )
110+ |> Repo . one! ( )
111+
112+ IO . inspect ( % { comment_id: comment_id , reason: reason , video_id: video_id } )
107113 Flagger . flag! ( user . id , video_id , comment_id , reason )
108- { :ok , % { id: comment_id } }
114+ { :ok , % { id: comment_id , video_id: video_id } }
109115 end
110116
111117 # Helper function to calculate vote value diff (matches comments_channel.ex logic)
0 commit comments