feat: implement submission repository and service layer with caching support
All checks were successful
Build and Release / release (push) Successful in 1m32s

This commit is contained in:
2026-05-24 13:11:40 +07:00
parent 9dacfd036d
commit 5a75798609
4 changed files with 117 additions and 30 deletions

View File

@@ -159,6 +159,50 @@ func (q *Queries) DeleteSubmission(ctx context.Context, id pgtype.UUID) error {
return err
}
const getLatestApprovedSubmission = `-- name: GetLatestApprovedSubmission :one
SELECT
id, project_id, commit_id, user_id, created_at, status, reviewed_by, reviewed_at, review_note, content, is_deleted
FROM submissions
WHERE project_id = $1
AND status = 2
AND is_deleted = false
ORDER BY reviewed_at DESC, created_at DESC
LIMIT 1
`
type GetLatestApprovedSubmissionRow struct {
ID pgtype.UUID `json:"id"`
ProjectID pgtype.UUID `json:"project_id"`
CommitID pgtype.UUID `json:"commit_id"`
UserID pgtype.UUID `json:"user_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
Status int16 `json:"status"`
ReviewedBy pgtype.UUID `json:"reviewed_by"`
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
ReviewNote pgtype.Text `json:"review_note"`
Content pgtype.Text `json:"content"`
IsDeleted bool `json:"is_deleted"`
}
func (q *Queries) GetLatestApprovedSubmission(ctx context.Context, projectID pgtype.UUID) (GetLatestApprovedSubmissionRow, error) {
row := q.db.QueryRow(ctx, getLatestApprovedSubmission, projectID)
var i GetLatestApprovedSubmissionRow
err := row.Scan(
&i.ID,
&i.ProjectID,
&i.CommitID,
&i.UserID,
&i.CreatedAt,
&i.Status,
&i.ReviewedBy,
&i.ReviewedAt,
&i.ReviewNote,
&i.Content,
&i.IsDeleted,
)
return i, err
}
const getLatestApprovedSubmissionExcluding = `-- name: GetLatestApprovedSubmissionExcluding :one
SELECT
id, project_id, commit_id, user_id, created_at, status, reviewed_by, reviewed_at, review_note, content, is_deleted