@ -12,6 +12,21 @@ export class CalendarChannelRepository {
|
||||
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
|
||||
) {}
|
||||
|
||||
public async getAll(
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<ObjectRecord<CalendarChannelObjectMetadata>[]> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
return await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT * FROM ${dataSourceSchema}."calendarChannel"`,
|
||||
[],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
}
|
||||
|
||||
public async getByConnectedAccountId(
|
||||
connectedAccountId: string,
|
||||
workspaceId: string,
|
||||
|
||||
@ -160,14 +160,14 @@ export class CalendarEventParticipantRepository {
|
||||
);
|
||||
}
|
||||
|
||||
public async updateCalendarEventParticipants(
|
||||
public async updateCalendarEventParticipantsAndReturnNewOnes(
|
||||
calendarEventParticipants: CalendarEventParticipant[],
|
||||
iCalUIDCalendarEventIdMap: Map<string, string>,
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<void> {
|
||||
): Promise<CalendarEventParticipant[]> {
|
||||
if (calendarEventParticipants.length === 0) {
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
|
||||
const dataSourceSchema =
|
||||
@ -189,6 +189,14 @@ export class CalendarEventParticipantRepository {
|
||||
calendarEventParticipant.handle,
|
||||
);
|
||||
|
||||
const newCalendarEventParticipants = differenceWith(
|
||||
calendarEventParticipants,
|
||||
existingCalendarEventParticipants,
|
||||
(calendarEventParticipant, existingCalendarEventParticipant) =>
|
||||
calendarEventParticipant.handle ===
|
||||
existingCalendarEventParticipant.handle,
|
||||
);
|
||||
|
||||
await this.deleteByIds(
|
||||
calendarEventParticipantsToDelete.map(
|
||||
(calendarEventParticipant) => calendarEventParticipant.id,
|
||||
@ -227,6 +235,8 @@ export class CalendarEventParticipantRepository {
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
return newCalendarEventParticipants;
|
||||
}
|
||||
|
||||
public async getWithoutPersonIdAndWorkspaceMemberId(
|
||||
|
||||
@ -80,34 +80,36 @@ export class CalendarEventRepository {
|
||||
}
|
||||
|
||||
public async getICalUIDCalendarEventIdMap(
|
||||
iCalUIDs: string[],
|
||||
calendarEventIds: string[],
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<Map<string, string>> {
|
||||
if (iCalUIDs.length === 0) {
|
||||
if (calendarEventIds.length === 0) {
|
||||
return new Map();
|
||||
}
|
||||
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const calendarEvents: {
|
||||
id: string;
|
||||
iCalUID: string;
|
||||
}[] = await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT id, "iCalUID" FROM ${dataSourceSchema}."calendarEvent" WHERE "iCalUID" = ANY($1)`,
|
||||
[iCalUIDs],
|
||||
const calendarEvents:
|
||||
| {
|
||||
id: string;
|
||||
iCalUID: string;
|
||||
}[]
|
||||
| undefined = await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT id, "iCalUID" FROM ${dataSourceSchema}."calendarEvent" WHERE "id" = ANY($1)`,
|
||||
[calendarEventIds],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
const iCalUIDsCalendarEvnetIdsMap = new Map<string, string>();
|
||||
const iCalUIDsCalendarEventIdsMap = new Map<string, string>();
|
||||
|
||||
calendarEvents.forEach((calendarEvent) => {
|
||||
iCalUIDsCalendarEvnetIdsMap.set(calendarEvent.iCalUID, calendarEvent.id);
|
||||
calendarEvents?.forEach((calendarEvent) => {
|
||||
iCalUIDsCalendarEventIdsMap.set(calendarEvent.iCalUID, calendarEvent.id);
|
||||
});
|
||||
|
||||
return iCalUIDsCalendarEvnetIdsMap;
|
||||
return iCalUIDsCalendarEventIdsMap;
|
||||
}
|
||||
|
||||
public async saveCalendarEvents(
|
||||
|
||||
Reference in New Issue
Block a user