From: Kai Moritz Date: Wed, 28 Dec 2022 16:20:53 +0000 (+0100) Subject: feat: `Chatroom.getMessages()` is fully paginated (takes first and last) X-Git-Tag: TEST~65 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=458ac6a901ae56e99873cc74a1acba25cfc95118;p=demos%2Fkafka%2Fchat feat: `Chatroom.getMessages()` is fully paginated (takes first and last) --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java b/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java index 62c97327..115dcd69 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java @@ -72,12 +72,16 @@ public class Chatroom return sink.asFlux(); } - public Stream getMessages(long firstMessage) + public Stream getMessages(long first, long last) { return messages .values() .stream() - .filter(message -> message.getSerialNumber() >= firstMessage); + .filter(message -> + { + long serial = message.getSerialNumber(); + return serial >= first && serial <= last; + }); }