性能
This commit is contained in:
+24
-17
@@ -118,18 +118,19 @@ function buildSeedOperations(state) {
|
||||
add(
|
||||
`INSERT INTO exams (
|
||||
id, code, name, description, registration_start, registration_end, exam_start, exam_end,
|
||||
admit_download_start, admit_download_end, location, status, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
admit_download_start, admit_download_end, location, pass_policy, pass_value, status, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
exam.id, exam.code, exam.name, exam.description || '', exam.registrationStart, exam.registrationEnd,
|
||||
exam.examStart, exam.examEnd, exam.admitDownloadStart, exam.admitDownloadEnd, exam.location || '',
|
||||
exam.status, exam.createdAt
|
||||
exam.passPolicy || 'score_ratio', Number(exam.passValue ?? 60), exam.status, exam.createdAt
|
||||
);
|
||||
exam.subjects.forEach((subject, index) => add(
|
||||
`INSERT INTO exam_subjects (
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, full_score, pass_score, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
subject.id, exam.id, subject.name, subject.date || String(exam.examStart).slice(0, 10),
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.order || index + 1)
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.fullScore || 150),
|
||||
Number(subject.passScore ?? Number(subject.fullScore || 150) * .6), Number(subject.order || index + 1)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -303,6 +304,8 @@ function stateFromRows(rows) {
|
||||
start: row.start_time,
|
||||
end: row.end_time,
|
||||
fee: Number(row.fee),
|
||||
fullScore: Number(row.full_score ?? 150),
|
||||
passScore: Number(row.pass_score ?? 90),
|
||||
order: Number(row.position)
|
||||
};
|
||||
const subjects = subjectsByExam.get(row.exam_id) || [];
|
||||
@@ -437,6 +440,8 @@ function stateFromRows(rows) {
|
||||
admitDownloadStart: row.admit_download_start,
|
||||
admitDownloadEnd: row.admit_download_end,
|
||||
location: row.location,
|
||||
passPolicy: row.pass_policy || 'score_ratio',
|
||||
passValue: Number(row.pass_value ?? 60),
|
||||
status: row.status,
|
||||
createdAt: row.created_at,
|
||||
subjects: subjectsByExam.get(row.id) || []
|
||||
@@ -1110,18 +1115,19 @@ function createRepository({ client, location, read, transaction, close }) {
|
||||
const operations = [operation(
|
||||
`INSERT INTO exams (
|
||||
id, code, name, description, registration_start, registration_end, exam_start, exam_end,
|
||||
admit_download_start, admit_download_end, location, status, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
admit_download_start, admit_download_end, location, pass_policy, pass_value, status, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
exam.id, exam.code, exam.name, exam.description || '', exam.registrationStart, exam.registrationEnd,
|
||||
exam.examStart, exam.examEnd, exam.admitDownloadStart, exam.admitDownloadEnd,
|
||||
exam.location || '', exam.status, exam.createdAt
|
||||
exam.location || '', exam.passPolicy, exam.passValue, exam.status, exam.createdAt
|
||||
)];
|
||||
exam.subjects.forEach((subject, index) => operations.push(operation(
|
||||
`INSERT INTO exam_subjects (
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, full_score, pass_score, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
subject.id, exam.id, subject.name, subject.date || String(exam.examStart).slice(0, 10),
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.order || index + 1)
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.fullScore),
|
||||
Number(subject.passScore), Number(subject.order || index + 1)
|
||||
)));
|
||||
operations.push(auditOperation(log));
|
||||
await transaction(operations);
|
||||
@@ -1132,20 +1138,21 @@ function createRepository({ client, location, read, transaction, close }) {
|
||||
`UPDATE exams SET
|
||||
code = ?, name = ?, description = ?, registration_start = ?, registration_end = ?,
|
||||
exam_start = ?, exam_end = ?, admit_download_start = ?, admit_download_end = ?,
|
||||
location = ?, status = ? WHERE id = ?`,
|
||||
location = ?, pass_policy = ?, pass_value = ?, status = ? WHERE id = ?`,
|
||||
exam.code, exam.name, exam.description || '', exam.registrationStart, exam.registrationEnd,
|
||||
exam.examStart, exam.examEnd, exam.admitDownloadStart, exam.admitDownloadEnd,
|
||||
exam.location || '', exam.status, exam.id
|
||||
exam.location || '', exam.passPolicy, exam.passValue, exam.status, exam.id
|
||||
)
|
||||
];
|
||||
if (replaceSubjects) {
|
||||
operations.push(operation('DELETE FROM exam_subjects WHERE exam_id = ?', exam.id));
|
||||
exam.subjects.forEach((subject, index) => operations.push(operation(
|
||||
`INSERT INTO exam_subjects (
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
id, exam_id, name, subject_date, start_time, end_time, fee, full_score, pass_score, position
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
subject.id, exam.id, subject.name, subject.date || String(exam.examStart).slice(0, 10),
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.order || index + 1)
|
||||
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.fullScore),
|
||||
Number(subject.passScore), Number(subject.order || index + 1)
|
||||
)));
|
||||
}
|
||||
operations.push(auditOperation(log));
|
||||
|
||||
Reference in New Issue
Block a user