Skip to content

Commit

Permalink
Server: Run data importing job using parallel stream
Browse files Browse the repository at this point in the history
This way, stock data is not fetched sequentially. This reduces fetching
time from ~22 seconds to ~7 seconds on my machine.
  • Loading branch information
StenAL committed Mar 30, 2023
1 parent cc9393e commit 08b7733
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void updateAllStocks() {
batchRepository.save(batch);

List<Stock> stocks = BALTIC_MAIN_LIST_ISINS.stream()
.parallel()
.map(stockDataImportingService::fetchData)
.flatMap(Optional::stream)
.toList();
Expand Down

0 comments on commit 08b7733

Please sign in to comment.