Skip to content

Commit

Permalink
Merge pull request #287 from bakaphp/refact-group-messages
Browse files Browse the repository at this point in the history
refact: group message
  • Loading branch information
jerlyrosa authored Aug 29, 2024
2 parents 59fe30a + b0c242b commit a99ce7b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8.0",
"version": "0.8.1",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
22 changes: 16 additions & 6 deletions src/modules/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,23 @@ export class Messages {
}

public async getMessagesGroupByDate(
where: WhereCondition,
hasAppModuleMessageWhere: HasAppModuleMessageWhereConditions,
orderBy: Array<OrderByMessage>,
search: string,
first: number,
page: number
options: {
where?: WhereCondition,
hasAppModuleMessageWhere?: HasAppModuleMessageWhereConditions,
orderBy?: Array<OrderByMessage>,
search?: string,
first?: number,
page?: number
} = {}
): Promise<MessagesInterface[]> {
const {
where,
hasAppModuleMessageWhere,
orderBy,
search,
first,
page,
} = options
const response = await this.client.query({
query: GET_MESSAGES_GROUP_BY_DATE_QUERY,
variables: {
Expand Down
19 changes: 8 additions & 11 deletions test/message.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HasAppModuleMessageWhereConditions, WhereCondition } from '../src';
import { WhereCondition } from '../src';
import { initializeClient, getClient } from './setupClient';

beforeAll(async () => {
Expand Down Expand Up @@ -132,8 +132,8 @@ describe('Test the Social Messages', () => {
expect(newMessage.id).toBeDefined();
expect(newMessage.message).toBe(messageContent);

const recentMessages = await messages.getMessages({
search: 'Kanvas'
const recentMessages = await messages.getMessages({
search: 'Kanvas'
});
expect(recentMessages).toBeDefined();
});
Expand Down Expand Up @@ -234,14 +234,11 @@ describe('Test the Social Messages', () => {
it('get messages group by date', async () => {
const client = getClient();
const messages = client.messages;
const recentMessages = await messages.getMessagesGroupByDate(
{} as WhereCondition,
{} as HasAppModuleMessageWhereConditions,
[{ column: 'CREATED_AT', order: 'DESC' }],
'',
25,
1
);
const recentMessages = await messages.getMessagesGroupByDate({
orderBy: [{ column: 'CREATED_AT', order: 'DESC' }],
first: 25,
page: 1
});
expect(recentMessages).toBeDefined();
});

Expand Down

0 comments on commit a99ce7b

Please sign in to comment.