|
6 | 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
7 | 7 | import org.springframework.core.env.Environment; |
8 | 8 | import si.inspirited.dto.RowDto; |
| 9 | +import si.inspirited.persistence.model.Quotation; |
9 | 10 | import si.inspirited.service.IAdvancedCollectorService; |
10 | 11 | import si.inspirited.service.ICollectorService; |
11 | 12 | import si.inspirited.service.IEnabledStatusFilter; |
@@ -42,18 +43,22 @@ public static void main(String[] args) { |
42 | 43 | } |
43 | 44 | @Override |
44 | 45 | public void run(String... args) throws Exception { |
45 | | - |
46 | | - |
47 | | - |
48 | | - while (true) { |
49 | | - consolePrinter.startPrintingConclusions(); |
50 | | - List<RowDto> enabledCompanies = enabledStatusFilter.getEnabled(collectorService.getSnapshot(env.getProperty("url.source.allCompaniesReview"), env.getProperty("token"))); |
| 46 | + ExecutorService executorService = Executors.newFixedThreadPool(10); |
| 47 | + boolean isPrinterStarted = false; |
| 48 | + boolean isMainProcessRunning = true; |
| 49 | + while (isMainProcessRunning) { |
| 50 | + List<RowDto> enabledCompanies; |
| 51 | + enabledCompanies = enabledStatusFilter.getEnabled(collectorService.getSnapshot(env.getProperty("url.source.allCompaniesReview"), env.getProperty("token"))); |
51 | 52 | for (RowDto company : enabledCompanies) { |
52 | | - ExecutorService executorService = Executors.newFixedThreadPool(10); |
53 | 53 | executorService.submit(() -> { |
54 | | - quotationService.addQuotation(advancedCollectorService.getExtendedCompanySnapshot(env.getProperty("url.source.extendedCompanyReview"), company.getSymbol(), env.getProperty("token"))); |
| 54 | + Quotation q = advancedCollectorService.getExtendedCompanySnapshot(env.getProperty("url.source.extendedCompanyReview"), company.getSymbol(), env.getProperty("token")); |
| 55 | + quotationService.addQuotation(q); |
55 | 56 | }); |
56 | 57 | } |
| 58 | + if (!isPrinterStarted) { |
| 59 | + executorService.submit(consolePrinter.startPrintingConclusions()); |
| 60 | + isPrinterStarted = true; |
| 61 | + } |
57 | 62 | } |
58 | 63 | } |
59 | 64 | } |
0 commit comments