feat(ECR-012–016): 合规、题库、时辰刷新、头像、MBTI OEJTS 与埋点

落地输入合规、探索题库、报告日/时辰刷新、账号头像、OEJTS 量表,并补齐 H5 埋点与 Admin 漏斗;同步 ESS 工件、切至自建 Git、清理 GitHub Actions。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-13 01:27:58 +08:00
co-authored by Cursor
parent 13860bf1ef
commit 89756f65b4
227 changed files with 7405 additions and 1407 deletions
@@ -28,6 +28,8 @@ type ScaleDetail struct {
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
Access string `json:"access,omitempty"` // free | membership
Locked bool `json:"locked,omitempty"`
Questions []ScaleQuestion `json:"questions"`
}
@@ -171,6 +173,24 @@ func (r *ScaleRepo) SaveResult(ctx context.Context, userID, scaleID, profileID u
return id, err
}
// LatestResult returns the newest result for user + published slug.
func (r *ScaleRepo) LatestResult(ctx context.Context, userID uuid.UUID, slug string) (*ScaleResultRow, error) {
var row ScaleResultRow
err := r.Pool.QueryRow(ctx, `
SELECT sr.id, s.slug, sr.result
FROM scale_results sr
JOIN scales s ON s.id = sr.scale_id
WHERE sr.user_id = $1 AND s.slug = $2 AND s.deleted_at IS NULL
AND sr.deleted_at IS NULL
ORDER BY sr.created_at DESC
LIMIT 1`, userID, slug,
).Scan(&row.ID, &row.ScaleSlug, &row.Result)
if err != nil {
return nil, err
}
return &row, nil
}
// ScaleIDBySlug resolves id for a published scale.
func (r *ScaleRepo) ScaleIDBySlug(ctx context.Context, slug string) (uuid.UUID, error) {
var id uuid.UUID
@@ -179,3 +199,20 @@ func (r *ScaleRepo) ScaleIDBySlug(ctx context.Context, slug string) (uuid.UUID,
WHERE slug=$1 AND status='published' AND deleted_at IS NULL`, slug).Scan(&id)
return id, err
}
// EnsurePublished upserts scale metadata (curated bank stubs; questions served from embed).
func (r *ScaleRepo) EnsurePublished(ctx context.Context, slug, title, description string) (uuid.UUID, error) {
var id uuid.UUID
err := r.Pool.QueryRow(ctx, `
INSERT INTO scales (slug, title, description, status)
VALUES ($1,$2,$3,'published')
ON CONFLICT (slug) DO UPDATE SET
title=EXCLUDED.title,
description=EXCLUDED.description,
status='published',
updated_at=now(),
deleted_at=NULL
RETURNING id`, slug, title, description,
).Scan(&id)
return id, err
}