Skip to content

Commit 5cf0088

Browse files
suyash-naithaniwtrocki
authored andcommitted
feat(api-mock): Add filtering for consumer groups and make search case insensitive (#79)
1 parent f90f294 commit 5cf0088

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/api-mock/src/handlers/kafka-admin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ module.exports = {
55
getConsumerGroups: async (c, req, res) => {
66
let consumerGroupList = consumerGroups;
77
let count = consumerGroups !== undefined ? consumerGroups.length : 0;
8+
9+
const filteredConsumerGroups = () => {
10+
let regexp = new RegExp(`${req.query.groupIdFilter.trim()}`,`i`);
11+
return consumerGroups.filter((consumerGroup) => regexp.test(consumerGroup.groupId));
12+
};
13+
if (consumerGroups && req.query.groupIdFilter && req.query.groupIdFilter.trim() !== '') {
14+
consumerGroupList = filteredConsumerGroups();
15+
count = consumerGroupList.length;
16+
}
817

918
const filterConsumerGroups = (topicName) => {
1019
return consumerGroupList.filter((consumerGroup) => {
@@ -129,7 +138,7 @@ module.exports = {
129138
topicList = topics;
130139

131140
const filterTopics = () => {
132-
let regexp = new RegExp(`${req.query.filter.trim()}`);
141+
let regexp = new RegExp(`${req.query.filter.trim()}`,`i`);
133142
return topics.filter((topic) => regexp.test(topic.name));
134143
};
135144

0 commit comments

Comments
 (0)