Skip to content

Commit aa84560

Browse files
committed
some mix credo suggestions
1 parent c68f331 commit aa84560

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/cadet/assessments/assessments.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,8 @@ defmodule Cadet.Assessments do
30503050
base_query =
30513051
Answer
30523052
|> where(submission_id: ^id)
3053-
# [a] are bindings (in SQL it is similar to FROM answers "AS a"), this line's alias is INNER JOIN ... "AS q"
3053+
# [a] are bindings (in SQL it is similar to FROM answers "AS a"),
3054+
# this line's alias is INNER JOIN ... "AS q"
30543055
|> join(:inner, [a], q in assoc(a, :question))
30553056
|> join(:inner, [_, q], ast in assoc(q, :assessment))
30563057
|> join(:inner, [..., ast], ac in assoc(ast, :config))
@@ -3555,11 +3556,12 @@ defmodule Cadet.Assessments do
35553556
end
35563557

35573558
def get_llm_assessment_prompt(question_id) do
3558-
from(q in Question,
3559+
query = from(q in Question,
35593560
where: q.id == ^question_id,
35603561
join: a in assoc(q, :assessment),
35613562
select: a.llm_assessment_prompt
35623563
)
3563-
|> Repo.one()
3564+
3565+
Repo.one(query)
35643566
end
35653567
end

lib/cadet_web/controllers/generate_ai_comments.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ defmodule CadetWeb.AICodeAnalysisController do
100100
|> text("No answer found for the given submission and question_id")
101101

102102
_ ->
103-
# Get head of answers (should only be one answer for given submission and question since we filter to only 1 question)
103+
# Get head of answers (should only be one answer for given submission
104+
# and question since we filter to only 1 question)
104105
analyze_code(
105106
conn,
106107
hd(answers),
@@ -210,7 +211,8 @@ defmodule CadetWeb.AICodeAnalysisController do
210211
assessment_prompt
211212
) do
212213
formatted_answer =
213-
format_student_answer(answer)
214+
answer
215+
|> format_student_answer()
214216
|> Jason.encode!()
215217

216218
system_prompt = format_system_prompt(course_prompt, assessment_prompt, answer)

test/cadet_web/controllers/ai_code_analysis_controller_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule CadetWeb.AICodeAnalysisControllerTest do
55
alias Cadet.AIComments
66
alias Cadet.AIComments.AIComment
77
alias Cadet.Courses.Course
8-
alias Cadet.{Repo}
8+
alias Cadet.Repo
99

1010
setup do
1111
course_with_llm =

0 commit comments

Comments
 (0)