aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend
diff options
context:
space:
mode:
authornsfisis <54318333+nsfisis@users.noreply.github.com>2026-02-24 21:55:01 +0900
committerGitHub <noreply@github.com>2026-02-24 21:55:01 +0900
commit6d85a8f97c8c9e086f2f9b8c71fd730bff12af07 (patch)
tree4771498620c1d13ad5caa882f880943529e07aa1 /backend
parentb3379e09c5e724ca0a755da10f8a4d33427b09bf (diff)
parent6a939257294655dd5c1b5ada323dfdc7dfc013f3 (diff)
downloadphperkaigi-2026-albatross-6d85a8f97c8c9e086f2f9b8c71fd730bff12af07.tar.gz
phperkaigi-2026-albatross-6d85a8f97c8c9e086f2f9b8c71fd730bff12af07.tar.zst
phperkaigi-2026-albatross-6d85a8f97c8c9e086f2f9b8c71fd730bff12af07.zip
Merge pull request #8 from nsfisis/claude/find-missing-admin-features-mHZoD
Display usernames in submission lists and details
Diffstat (limited to 'backend')
-rw-r--r--backend/admin/handler.go31
-rw-r--r--backend/admin/handler_test.go8
-rw-r--r--backend/admin/templates/problems.html1
-rw-r--r--backend/admin/templates/submission_detail.html2
-rw-r--r--backend/admin/templates/submissions.html2
5 files changed, 39 insertions, 5 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go
index f115745..fcf85a3 100644
--- a/backend/admin/handler.go
+++ b/backend/admin/handler.go
@@ -530,16 +530,28 @@ func (h *Handler) getSubmissions(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid game_id")
}
- submissions, err := h.q.GetSubmissionsByGameID(c.Request().Context(), int32(gameID))
+ ctx := c.Request().Context()
+
+ submissions, err := h.q.GetSubmissionsByGameID(ctx, int32(gameID))
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
+ userRows, err := h.q.ListUsers(ctx)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
+ }
+ usernameMap := make(map[int32]string, len(userRows))
+ for _, u := range userRows {
+ usernameMap[u.UserID] = u.Username
+ }
+
entries := make([]echo.Map, len(submissions))
for i, r := range submissions {
entries[i] = echo.Map{
"SubmissionID": r.SubmissionID,
"UserID": r.UserID,
+ "Username": usernameMap[r.UserID],
"Status": r.Status,
"CodeSize": r.CodeSize,
"CreatedAt": r.CreatedAt.Time.In(jst).Format("2006-01-02T15:04"),
@@ -565,7 +577,9 @@ func (h *Handler) getSubmissionDetail(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid submission_id")
}
- submission, err := h.q.GetSubmissionByID(c.Request().Context(), int32(submissionID))
+ ctx := c.Request().Context()
+
+ submission, err := h.q.GetSubmissionByID(ctx, int32(submissionID))
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return echo.NewHTTPError(http.StatusNotFound)
@@ -573,7 +587,17 @@ func (h *Handler) getSubmissionDetail(c echo.Context) error {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
- testcaseResultRows, err := h.q.GetTestcaseResultsBySubmissionID(c.Request().Context(), int32(submissionID))
+ var username string
+ user, err := h.q.GetUserByID(ctx, submission.UserID)
+ if err != nil {
+ if !errors.Is(err, pgx.ErrNoRows) {
+ return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
+ }
+ } else {
+ username = user.Username
+ }
+
+ testcaseResultRows, err := h.q.GetTestcaseResultsBySubmissionID(ctx, int32(submissionID))
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
@@ -596,6 +620,7 @@ func (h *Handler) getSubmissionDetail(c echo.Context) error {
"Submission": echo.Map{
"SubmissionID": submission.SubmissionID,
"UserID": submission.UserID,
+ "Username": username,
"Status": submission.Status,
"CodeSize": submission.CodeSize,
"CreatedAt": submission.CreatedAt.Time.In(jst).Format("2006-01-02T15:04"),
diff --git a/backend/admin/handler_test.go b/backend/admin/handler_test.go
index 994c584..f340fef 100644
--- a/backend/admin/handler_test.go
+++ b/backend/admin/handler_test.go
@@ -1182,6 +1182,11 @@ func TestGetSubmissions_Success(t *testing.T) {
},
}, nil
},
+ listUsersFunc: func(_ context.Context) ([]db.User, error) {
+ return []db.User{
+ {UserID: 1, Username: "alice"},
+ }, nil
+ },
}
h := newTestHandler(q)
@@ -1208,6 +1213,9 @@ func TestGetSubmissionDetail_Success(t *testing.T) {
CreatedAt: pgtype.Timestamp{Valid: true},
}, nil
},
+ getUserByIDFunc: func(_ context.Context, userID int32) (db.User, error) {
+ return db.User{UserID: userID, Username: "alice"}, nil
+ },
getTestcaseResultsBySubmIDFunc: func(_ context.Context, _ int32) ([]db.TestcaseResult, error) {
return []db.TestcaseResult{
{
diff --git a/backend/admin/templates/problems.html b/backend/admin/templates/problems.html
index 120789e..c5fc290 100644
--- a/backend/admin/templates/problems.html
+++ b/backend/admin/templates/problems.html
@@ -14,6 +14,7 @@
<a href="{{ $.BasePath }}admin/problems/{{ .ProblemID }}">
{{ .Title }} (id={{ .ProblemID }} language={{ .Language }})
</a>
+ | <a href="{{ $.BasePath }}admin/problems/{{ .ProblemID }}/testcases">Testcases</a>
</li>
{{ end }}
</ul>
diff --git a/backend/admin/templates/submission_detail.html b/backend/admin/templates/submission_detail.html
index ed601ba..b4c82d0 100644
--- a/backend/admin/templates/submission_detail.html
+++ b/backend/admin/templates/submission_detail.html
@@ -12,7 +12,7 @@
<h3>Basics</h3>
<ul>
- <li>User: {{ .Submission.UserID }}</li>
+ <li>User: {{ .Submission.Username }} (id={{ .Submission.UserID }})</li>
<li>Status: {{ .Submission.Status }}</li>
<li>Code Size: {{ .Submission.CodeSize }}</li>
<li>Created At: {{ .Submission.CreatedAt }}</li>
diff --git a/backend/admin/templates/submissions.html b/backend/admin/templates/submissions.html
index c53c5b3..b0368d7 100644
--- a/backend/admin/templates/submissions.html
+++ b/backend/admin/templates/submissions.html
@@ -29,7 +29,7 @@
{{ range .Submissions }}
<tr>
<td>{{ .SubmissionID }}</td>
- <td>{{ .UserID }}</td>
+ <td>{{ .Username }} (id={{ .UserID }})</td>
<td>{{ .Status }}</td>
<td>{{ .CodeSize }}</td>
<td>{{ .CreatedAt }}</td>