fix: move task allocation index creation out of runtime

main
陈沅 5 days ago
parent a2e733f309
commit d9c5ad27e7

@ -208,7 +208,6 @@ public class TrainingTaskServiceImpl implements TrainingTaskService {
}
sort++;
}
ensureTaskAllocationClassIndex();
defaultTasksInitialized = true;
}
}
@ -716,14 +715,6 @@ public class TrainingTaskServiceImpl implements TrainingTaskService {
trainingTaskClassConfigTableChecked = true;
}
private void ensureTaskAllocationClassIndex() {
if (jdbcTemplate == null) {
return;
}
jdbcTemplate.execute("CREATE INDEX IF NOT EXISTS idx_task_allocation_class_disabled_module "
+ "ON task_allocation (class_id, disabled_status, module)");
}
TrainingTask buildTask(TrainingTaskImportDTO row, int rowNumber, List<String> errors) {
String projectName = StringUtils.trimToEmpty(row.getProjectName());
String taskKey = StringUtils.trimToEmpty(row.getTaskKey());

@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
@ -38,6 +39,19 @@ import static org.mockito.Mockito.when;
class TrainingTaskServiceImplTest {
@Test
void defaultTaskInitializationDoesNotRunTaskAllocationSchemaDdl() {
TrainingTaskServiceImpl service = new TrainingTaskServiceImpl();
service.trainingTaskMapper = mock(TrainingTaskMapper.class);
service.jdbcTemplate = mock(JdbcTemplate.class);
when(service.trainingTaskMapper.selectByTaskKey(anyString()))
.thenReturn(storedTask("existing-task", "new-product-survey"));
service.ensureDefaultTasks(null);
verify(service.jdbcTemplate, never()).execute(contains("task_allocation"));
}
@Test
void splitListSupportsCommonSeparators() {
TrainingTaskServiceImpl service = new TrainingTaskServiceImpl();

Loading…
Cancel
Save