Fix performance issue mail (#5780)
In this PR, I'm mainly doing two things: - uniformizing messaging-messages-import and messaging-message-list-fetch behaviors (cron.job and job) - improving performances of these cron.jobs by not triggering the jobs if the stage is not relevant - making sure these jobs have same signature (workspaceId + messageChannelId)
This commit is contained in:
@ -19,7 +19,12 @@ export class MessageChannelRepository {
|
||||
public async create(
|
||||
messageChannel: Pick<
|
||||
ObjectRecord<MessageChannelWorkspaceEntity>,
|
||||
'id' | 'connectedAccountId' | 'type' | 'handle' | 'visibility'
|
||||
| 'id'
|
||||
| 'connectedAccountId'
|
||||
| 'type'
|
||||
| 'handle'
|
||||
| 'visibility'
|
||||
| 'syncStatus'
|
||||
>,
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
@ -28,14 +33,15 @@ export class MessageChannelRepository {
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`INSERT INTO ${dataSourceSchema}."messageChannel" ("id", "connectedAccountId", "type", "handle", "visibility")
|
||||
VALUES ($1, $2, $3, $4, $5)`,
|
||||
`INSERT INTO ${dataSourceSchema}."messageChannel" ("id", "connectedAccountId", "type", "handle", "visibility", "syncStatus")
|
||||
VALUES ($1, $2, $3, $4, $5, $6)`,
|
||||
[
|
||||
messageChannel.id,
|
||||
messageChannel.connectedAccountId,
|
||||
messageChannel.type,
|
||||
messageChannel.handle,
|
||||
messageChannel.visibility,
|
||||
messageChannel.syncStatus,
|
||||
],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
@ -138,6 +144,25 @@ export class MessageChannelRepository {
|
||||
);
|
||||
}
|
||||
|
||||
public async getById(
|
||||
id: string,
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<ObjectRecord<MessageChannelWorkspaceEntity>> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const messageChannels =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT * FROM ${dataSourceSchema}."messageChannel" WHERE "id" = $1`,
|
||||
[id],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
return messageChannels[0];
|
||||
}
|
||||
|
||||
public async getIdsByWorkspaceMemberId(
|
||||
workspaceMemberId: string,
|
||||
workspaceId: string,
|
||||
|
||||
Reference in New Issue
Block a user