Skip to content

Commit

Permalink
Merge pull request #378 from OpenElements/demodata
Browse files Browse the repository at this point in the history
Created DemoDataInitializer on server startup
  • Loading branch information
Ndacyayisenga-droid authored May 7, 2024
2 parents 8043168 + 3d4d6fb commit 155c96f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public long getMeasurementCount() {
return entityManager.createQuery("SELECT COUNT(m) FROM Measurement m", Long.class).getSingleResult();
}

@Transactional
@PostMapping("/create-test-data")
public void createTestData() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.openelements.benchscape.server.store.endpoints;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class DemoDataInitializer implements ApplicationRunner {

private final DebugEndpoint debugEndpoint;

@Autowired
public DemoDataInitializer(DebugEndpoint debugEndpoint) {
this.debugEndpoint = debugEndpoint;
}

@Override
public void run(ApplicationArguments args) {
int numberOfRuns = 5;

for (int i = 0; i < numberOfRuns; i++) {
debugEndpoint.createTestData();
}
}
}

0 comments on commit 155c96f

Please sign in to comment.