Skip to content

Commit 6a141a4

Browse files
committed
Re-factor schema
1 parent c0c434a commit 6a141a4

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/cadet/ai_comments/ai_comment.ex

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ defmodule Cadet.AIComments.AIComment do
1818
timestamps()
1919
end
2020

21+
@required_fields ~w(answer_id raw_prompt answers_json)a
22+
@optional_fields ~w(response error final_comment)a
23+
2124
def changeset(ai_comment, attrs) do
2225
ai_comment
23-
|> cast(attrs, [
24-
:answer_id,
25-
:raw_prompt,
26-
:answers_json,
27-
:response,
28-
:error,
29-
:final_comment
30-
])
31-
|> validate_required([:answer_id, :raw_prompt, :answers_json])
26+
|> cast(attrs, @required_fields ++ @optional_fields)
27+
|> validate_required(@required_fields)
3228
|> foreign_key_constraint(:answer_id)
3329
end
3430
end

0 commit comments

Comments
 (0)