Skip to content

Commit 009b26a

Browse files
committed
local-problem-answersを修正した
1 parent a899efa commit 009b26a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

vmdb-api/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (c *Controller) listLatestUnconfirmedAnswersForLocalProblem(w http.Response
129129
continue
130130
}
131131

132-
answers, err := c.repo.listLatestUnconfirmedAnswersFor(ctx, problem.ID)
132+
answers, err := c.repo.listLatestUnscoredAnswersFor(ctx, problem.ID)
133133
if err != nil {
134134
slog.ErrorContext(ctx, "failed to list latest unconfirmed Answers", "error", err)
135135
w.WriteHeader(http.StatusInternalServerError)

vmdb-api/repository.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ func (r *Repository) findProblemBy(ctx context.Context, code string) (*Problem,
6161
return &result, nil
6262
}
6363

64-
func (r *Repository) listLatestUnconfirmedAnswersFor(ctx context.Context, problemID uuid.UUID) ([]Answer, error) {
64+
func (r *Repository) listLatestUnscoredAnswersFor(ctx context.Context, problemID uuid.UUID) ([]Answer, error) {
6565
var result []Answer
66-
err := r.db.NewSelect().Model(&result).
67-
Where("confirming = ?", false).
66+
err := r.db.NewSelect().ColumnExpr("answers.*").
67+
Table("answers").
68+
Join("INNER JOIN scores").JoinOn("answers.id = scores.answer_id").
69+
Where("point IS NULL").
6870
Where("problem_id = ?", problemID).
6971
Order("created_at DESC").
70-
Scan(ctx)
72+
Scan(ctx, &result)
7173
if err != nil {
7274
return nil, err
7375
}

0 commit comments

Comments
 (0)