Skip to content

Commit

Permalink
fix: added tag for search
Browse files Browse the repository at this point in the history
  • Loading branch information
akp111 committed Sep 24, 2024
1 parent 583e709 commit 27a6eee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/restapi/src/lib/channels/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type SearchChannelOptionsType = {
page?: number;
limit?: number;
filter?: number;
tag?: string;
// temp fix to support both new and old format
oldFormat?: boolean;
};
Expand All @@ -25,6 +26,7 @@ export const search = async (options: SearchChannelOptionsType) => {
page = Constants.PAGINATION.INITIAL_PAGE,
limit = Constants.PAGINATION.LIMIT,
filter,
tag,
oldFormat = true,
} = options || {};

Expand All @@ -35,6 +37,7 @@ export const search = async (options: SearchChannelOptionsType) => {
page,
limit: getLimit(limit),
query,
...(tag && { tag }),
...(filter && { filter }),
};
const requestUrl = `${apiEndpoint}?${getQueryParams(queryObj)}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type ChannelSearchOptions = {
filter?: number;
// temp fix to support both new and old format
oldFormat?: boolean;
tag?: string;
};

// Types related to notification
Expand Down
2 changes: 2 additions & 0 deletions packages/restapi/src/lib/pushNotification/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ export class Channel extends PushNotificationBaseClass {
page = Constants.PAGINATION.INITIAL_PAGE,
limit = Constants.PAGINATION.LIMIT,
filter,
tag,
oldFormat = true
} = options || {};
return await PUSH_CHANNEL.search({
query: query,
page: page,
limit: limit,
filter: filter,
tag: tag,
env: this.env,
oldFormat
});
Expand Down
12 changes: 11 additions & 1 deletion packages/restapi/tests/lib/channel/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('PUSH_CHANNELS.search', () => {
console.log(res);
});

it.only('Should fetch channels based on the filter in new format', async () => {
it('Should fetch channels based on the filter in new format', async () => {
const res = await search({
filter: 80002,
env: ENV.DEV,
Expand All @@ -21,4 +21,14 @@ describe('PUSH_CHANNELS.search', () => {
});
console.log(res);
});

it('Should fetch channels based on the filter in new format', async () => {
const res = await search({
env: ENV.DEV,
query: "Channel",
oldFormat: false,
tag: "Infrastructure"
});
console.log(res);
});
});

0 comments on commit 27a6eee

Please sign in to comment.