feat: add feedback checkins exam dates

This commit is contained in:
Codex
2026-06-29 01:48:38 +08:00
parent 726d090a8e
commit 8f92d0427e
16 changed files with 1232 additions and 33 deletions

View File

@@ -54,6 +54,8 @@ const ids = {
recentPractice: '00000000-0000-0000-0000-000000000841',
tenantClass: '00000000-0000-0000-0000-000000000851',
tenantClassOther: '00000000-0000-0000-0000-000000000852',
examDate: '00000000-0000-0000-0000-000000000861',
examDateSchool: '00000000-0000-0000-0000-000000000862',
partnerTenant: '00000000-0000-0000-0000-000000000901',
partnerSubscription: '00000000-0000-0000-0000-000000000902',
partnerInvoice: '00000000-0000-0000-0000-000000000903',
@@ -69,6 +71,43 @@ async function main() {
try {
await client.query('begin');
await client.query(
`
delete from public.report_status_events
where tenant_id = $1
and report_id in (
select id from public.reports
where tenant_id = $1
and (
user_id in ($2::uuid, $3::uuid)
or question_id in ($4::uuid, $5::uuid)
)
)
`,
[tenantId, ids.user, ids.tenantAdminUser, ids.question, ids.questionTwo],
);
await client.query(
`
delete from public.reports
where tenant_id = $1
and (
user_id in ($2::uuid, $3::uuid)
or question_id in ($4::uuid, $5::uuid)
)
`,
[tenantId, ids.user, ids.tenantAdminUser, ids.question, ids.questionTwo],
);
await client.query(
`
delete from public.user_score_events
where tenant_id = $1
and user_id in ($2::uuid, $3::uuid)
`,
[tenantId, ids.user, ids.tenantAdminUser],
);
await client.query(
`
delete from public.crm_webhook_queue
@@ -252,6 +291,16 @@ async function main() {
[ids.user, ids.authUser],
);
await client.query(
`
update public.platform_users
set score = 0,
updated_at = now()
where id in ($1::uuid, $2::uuid)
`,
[ids.user, ids.tenantAdminUser],
);
await client.query(
`
insert into public.platform_users (id, auth_user_id, username, phone, name, primary_role, raw_profile)
@@ -389,6 +438,45 @@ async function main() {
[ids.region, tenantId],
);
await client.query(
`
update public.student_profiles
set region_id = $3,
last_check_in_date = null,
stats = stats - 'checkInStreak' - 'lastCheckInPoints',
updated_at = now()
where tenant_id = $1
and user_id in ($2::uuid, $4::uuid)
`,
[tenantId, ids.user, ids.region, ids.secondStudentUser],
);
await client.query(
`
insert into public.exam_dates (
id, tenant_id, region_id, school_id, legacy_id, exam_name,
exam_date, exam_type, description, metadata, sort_order, is_active
)
values (
$1, $2, $3, null, 'smoke-exam-date', '烟测统考',
'2030-06-15', 'unified', '用于验证学生端考试倒计时和租户后台考试日期维护',
'{"source":"smoke-seed"}'::jsonb, 1, true
)
on conflict (id)
do update set region_id = excluded.region_id,
school_id = excluded.school_id,
exam_name = excluded.exam_name,
exam_date = excluded.exam_date,
exam_type = excluded.exam_type,
description = excluded.description,
metadata = excluded.metadata,
sort_order = excluded.sort_order,
is_active = excluded.is_active,
updated_at = now()
`,
[ids.examDate, tenantId, ids.region],
);
await client.query(
`
insert into public.subjects (id, tenant_id, region_id, legacy_id, name, type, sort_order, is_active)