Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix after parameter on topic data pagination #1468

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions client/src/containers/Topic/Topic/TopicData/TopicData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,13 @@ class TopicData extends Root {
this.eventSource.addEventListener('searchBody', function (e) {
const res = JSON.parse(e.data);
const records = res.records || [];
const nextPage = res.after ? res.after : self.state.nextPage;

const percentDiff = res.percent - lastPercentVal;

// to avoid UI slowdowns, only update the percentage in fixed increments
if (percentDiff >= percentUpdateDelta) {
lastPercentVal = res.percent;
self.setState({
nextPage,
recordCount: self.state.recordCount + records.length,
percent: res.percent.toFixed(2)
});
Expand All @@ -207,9 +205,12 @@ class TopicData extends Root {
}
});

this.eventSource.addEventListener('searchEnd', function () {
this.eventSource.addEventListener('searchEnd', function (e) {
const res = JSON.parse(e.data);
const nextPage = res.after ? res.after : self.state.nextPage;
self.setState({ percent: 100, nextPage, isSearching: false, loading: false });

self.eventSource.close();
self.setState({ percent: 100, isSearching: false, loading: false });
});
}
);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/akhq/repositories/RecordRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,7 @@ public Flowable<Event<SearchEvent>> search(Topic topic, Options options) throws

// end
if (searchEvent == null || searchEvent.emptyPoll == 666) {

emitter.onNext(new SearchEvent(topic).end());
emitter.onNext(new SearchEvent(topic).end(searchEvent != null ? searchEvent.after: null));
emitter.onComplete();
consumer.close();

Expand Down Expand Up @@ -725,7 +724,7 @@ public Flowable<Event<SearchEvent>> search(Topic topic, Options options) throws

if (currentEvent.emptyPoll >= 1) {
currentEvent.emptyPoll = 666;
emitter.onNext(currentEvent.end());
emitter.onNext(currentEvent.end(searchEvent.getAfter()));
} else if (matchesCount.get() >= options.getSize()) {
currentEvent.emptyPoll = 666;
emitter.onNext(currentEvent.progress(options));
Expand Down Expand Up @@ -860,8 +859,9 @@ private SearchEvent(Topic topic) {
});
}

public Event<SearchEvent> end() {
public Event<SearchEvent> end(String after) {
this.percent = 100;
this.after = after;

return Event.of(this).name("searchEnd");
}
Expand Down