This commit is contained in:
2026-07-21 13:25:03 +08:00 Unverified
parent ae528b20e9
commit 1b6e860013
5 changed files with 35 additions and 8 deletions
+6 -2
View File
@@ -357,6 +357,10 @@ export function buildSeedOperations(state) {
}
function stateFromRows(rows) {
const parseJson = (value, fallback) => {
if (value != null && typeof value === 'object') return value;
try { return JSON.parse(value || JSON.stringify(fallback)); } catch { return fallback; }
};
const subjectsByExam = new Map();
for (const row of rows.subjects) {
const fullScore = Number(row.full_score ?? 150);
@@ -518,7 +522,7 @@ function stateFromRows(rows) {
postalCode: row.postal_code || '',
guardianName: row.guardian_name || '',
guardianPhone: row.guardian_phone || '',
specialtyTypes: (() => { try { return JSON.parse(row.specialty_types || '[]'); } catch { return []; } })(),
specialtyTypes: parseJson(row.specialty_types, []),
specialtyCertificate: row.specialty_certificate || '',
policyEligibility: row.policy_eligibility || '',
profileCompleted: Boolean(row.profile_completed),
@@ -759,7 +763,7 @@ function stateFromRows(rows) {
userId: row.user_id || null,
schoolId: row.school_id || null,
status: row.status,
payload: (() => { try { return JSON.parse(row.payload_json || '{}'); } catch { return {}; } })(),
payload: parseJson(row.payload_json, {}),
createdAt: row.created_at,
updatedAt: row.updated_at
})),