Skip to content

Commit

Permalink
feat(Exchange MVC): Sort by if stock has new news
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSapula committed May 25, 2026
1 parent f1eebb7 commit 853f9a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ExchangeController extends AbstractController<ExchangeModel> {
*/
public enum SortAction {
NONE,
NEWS,
GAINERS,
LOSERS
}
Expand Down Expand Up @@ -129,8 +130,14 @@ public void sortStocksBy(SortAction action) {
break;
}

case NEWS: {
stocksSorted.addAll(session.getExchange().getStocks()
.stream().filter(s -> s.getNewspaper().hasNewNews()).toList());
break;
}

case GAINERS: {
stocksSorted.addAll(session.getExchange().getGainers(Integer.MAX_VALUE)); // TODO: fix?
stocksSorted.addAll(session.getExchange().getGainers(Integer.MAX_VALUE));
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ public Parent createHeader() {
query -> searchQueryHandler.accept(query),
List.of(
"None",
"New news",
"Gainers (week)",
"Losers (week)"),
() -> sortHandle.accept(SortAction.NONE),
() -> sortHandle.accept(SortAction.NEWS),
() -> sortHandle.accept(SortAction.GAINERS),
() -> sortHandle.accept(SortAction.LOSERS));
}
Expand Down

0 comments on commit 853f9a9

Please sign in to comment.