feat: auto grant badges for learning milestones

This commit is contained in:
Codex
2026-06-30 14:24:07 +08:00
parent 9299552451
commit 7d2b8fd610
11 changed files with 343 additions and 19 deletions

View File

@@ -75,6 +75,9 @@ const ids = {
tenantScoreBadge: '00000000-0000-0000-0000-000000000874',
tenantFeedbackBadge: '00000000-0000-0000-0000-000000000875',
tenantActivityBadge: '00000000-0000-0000-0000-000000000876',
tenantPracticeBadge: '00000000-0000-0000-0000-000000000881',
tenantVocabularyBadge: '00000000-0000-0000-0000-000000000882',
tenantMockExamBadge: '00000000-0000-0000-0000-000000000883',
pointActivityTask: '00000000-0000-0000-0000-000000000877',
pointSystemTask: '00000000-0000-0000-0000-000000000878',
pointExchangeItem: '00000000-0000-0000-0000-000000000879',
@@ -357,13 +360,27 @@ async function main() {
tenantId,
ids.user,
ids.secondStudentUser,
[ids.tenantBadge, ids.tenantCheckInBadge, ids.tenantScoreBadge, ids.tenantFeedbackBadge, ids.tenantActivityBadge],
[
ids.tenantBadge,
ids.tenantCheckInBadge,
ids.tenantScoreBadge,
ids.tenantFeedbackBadge,
ids.tenantActivityBadge,
ids.tenantPracticeBadge,
ids.tenantVocabularyBadge,
ids.tenantMockExamBadge,
],
[
`badge:${ids.tenantBadge}:user:${ids.user}`,
`auto:${ids.tenantCheckInBadge}:user:${ids.user}`,
`auto:${ids.tenantScoreBadge}:user:${ids.user}`,
`auto:${ids.tenantFeedbackBadge}:user:${ids.user}`,
`auto:${ids.tenantActivityBadge}:user:${ids.user}`,
`auto:${ids.tenantPracticeBadge}:user:${ids.user}`,
`auto:${ids.tenantPracticeBadge}:user:${ids.tenantAdminUser}`,
`auto:${ids.tenantVocabularyBadge}:user:${ids.user}`,
`auto:${ids.tenantMockExamBadge}:user:${ids.user}`,
`auto:${ids.tenantMockExamBadge}:user:${ids.tenantAdminUser}`,
],
],
);
@@ -377,7 +394,19 @@ async function main() {
or coalesce(legacy_id, '') like 'integration-badge-%'
)
`,
[tenantId, [ids.tenantBadge, ids.tenantCheckInBadge, ids.tenantScoreBadge, ids.tenantFeedbackBadge, ids.tenantActivityBadge]],
[
tenantId,
[
ids.tenantBadge,
ids.tenantCheckInBadge,
ids.tenantScoreBadge,
ids.tenantFeedbackBadge,
ids.tenantActivityBadge,
ids.tenantPracticeBadge,
ids.tenantVocabularyBadge,
ids.tenantMockExamBadge,
],
],
);
await client.query(
@@ -969,6 +998,7 @@ async function main() {
`
update public.student_profiles
set region_id = $3,
avatar_preset = 'male',
last_check_in_date = null,
stats = stats - 'checkInStreak' - 'lastCheckInPoints',
updated_at = now()