-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into BC-7971-room-members
- Loading branch information
Showing
141 changed files
with
9,446 additions
and
760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './tsp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { TspSyncConfig } from './tsp-sync.config'; | ||
export { TspSyncStrategy } from './tsp-sync.strategy'; |
27 changes: 27 additions & 0 deletions
27
apps/server/src/infra/sync/tsp/loggable/tsp-schools-fetched.loggable.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { TspSchoolsFetchedLoggable } from './tsp-schools-fetched.loggable'; | ||
|
||
describe(TspSchoolsFetchedLoggable.name, () => { | ||
let loggable: TspSchoolsFetchedLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSchoolsFetchedLoggable(10, 5); | ||
}); | ||
|
||
describe('when loggable is initialized', () => { | ||
it('should be defined', () => { | ||
expect(loggable).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('getLogMessage', () => { | ||
it('should return a log message', () => { | ||
expect(loggable.getLogMessage()).toEqual({ | ||
message: `Fetched 10 schools for the last 5 days from TSP`, | ||
data: { | ||
tspSchoolCount: 10, | ||
daysFetched: 5, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
apps/server/src/infra/sync/tsp/loggable/tsp-schools-fetched.loggable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Loggable, LogMessage } from '@src/core/logger'; | ||
|
||
export class TspSchoolsFetchedLoggable implements Loggable { | ||
constructor(private readonly tspSchoolCount: number, private readonly daysFetched: number) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `Fetched ${this.tspSchoolCount} schools for the last ${this.daysFetched} days from TSP`, | ||
data: { | ||
tspSchoolCount: this.tspSchoolCount, | ||
daysFetched: this.daysFetched, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
apps/server/src/infra/sync/tsp/loggable/tsp-schools-synced.loggable.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TspSchoolsSyncedLoggable } from './tsp-schools-synced.loggable'; | ||
|
||
describe(TspSchoolsSyncedLoggable.name, () => { | ||
let loggable: TspSchoolsSyncedLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSchoolsSyncedLoggable(10, 10, 5, 5); | ||
}); | ||
|
||
describe('when loggable is initialized', () => { | ||
it('should be defined', () => { | ||
expect(loggable).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('getLogMessage', () => { | ||
it('should return a log message', () => { | ||
expect(loggable.getLogMessage()).toEqual({ | ||
message: `Synced schools: Of 10 schools 10 were processed. 5 were created and 5 were updated`, | ||
data: { | ||
tspSchoolCount: 10, | ||
processedSchools: 10, | ||
createdSchools: 5, | ||
updatedSchools: 5, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
apps/server/src/infra/sync/tsp/loggable/tsp-schools-synced.loggable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Loggable, LogMessage } from '@src/core/logger'; | ||
|
||
export class TspSchoolsSyncedLoggable implements Loggable { | ||
constructor( | ||
private readonly tspSchoolCount: number, | ||
private readonly processedSchools: number, | ||
private readonly createdSchools: number, | ||
private readonly updatedSchools: number | ||
) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `Synced schools: Of ${this.tspSchoolCount} schools ${this.processedSchools} were processed. ${this.createdSchools} were created and ${this.updatedSchools} were updated`, | ||
data: { | ||
tspSchoolCount: this.tspSchoolCount, | ||
processedSchools: this.processedSchools, | ||
createdSchools: this.createdSchools, | ||
updatedSchools: this.updatedSchools, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/server/src/infra/sync/tsp/loggable/tsp-schulnummer-missing.loggable.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { TspSchulnummerMissingLoggable } from './tsp-schulnummer-missing.loggable'; | ||
|
||
describe(TspSchulnummerMissingLoggable.name, () => { | ||
let loggable: TspSchulnummerMissingLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSchulnummerMissingLoggable('Schule'); | ||
}); | ||
|
||
describe('when loggable is initialized', () => { | ||
it('should be defined', () => { | ||
expect(loggable).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('getLogMessage', () => { | ||
it('should return a log message', () => { | ||
expect(loggable.getLogMessage()).toEqual({ | ||
message: `The TSP school 'Schule' is missing a Schulnummer. This school is skipped.`, | ||
data: { | ||
schulName: 'Schule', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
apps/server/src/infra/sync/tsp/loggable/tsp-schulnummer-missing.loggable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Loggable, LogMessage } from '@src/core/logger'; | ||
|
||
export class TspSchulnummerMissingLoggable implements Loggable { | ||
constructor(private readonly schulName?: string) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `The TSP school '${this.schulName ?? ''}' is missing a Schulnummer. This school is skipped.`, | ||
data: { | ||
schulName: this.schulName, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
apps/server/src/infra/sync/tsp/loggable/tsp-system-not-found.loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { TspSystemNotFoundLoggableException } from './tsp-system-not-found.loggable-exception'; | ||
|
||
describe(TspSystemNotFoundLoggableException.name, () => { | ||
let loggable: TspSystemNotFoundLoggableException; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSystemNotFoundLoggableException(); | ||
}); | ||
|
||
describe('when loggable is initialized', () => { | ||
it('should be defined', () => { | ||
expect(loggable).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('getLogMessage', () => { | ||
it('should return a log message', () => { | ||
expect(loggable.getLogMessage()).toEqual({ | ||
message: 'The TSP system could not be found during the sync', | ||
type: 'TSP_SYSTEM_NOT_FOUND', | ||
stack: expect.any(String), | ||
}); | ||
}); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
apps/server/src/infra/sync/tsp/loggable/tsp-system-not-found.loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { BusinessError, ErrorLogMessage } from '@shared/common'; | ||
import { Loggable, LogMessage } from '@src/core/logger'; | ||
|
||
export class TspSystemNotFoundLoggableException extends BusinessError implements Loggable { | ||
constructor() { | ||
super( | ||
{ | ||
type: 'TSP_SYSTEM_NOT_FOUND', | ||
title: 'The TSP system could not be found', | ||
defaultMessage: 'The TSP system could not be found during the sync', | ||
}, | ||
HttpStatus.BAD_REQUEST | ||
); | ||
} | ||
|
||
getLogMessage(): LogMessage | ErrorLogMessage { | ||
const message: LogMessage | ErrorLogMessage = { | ||
message: this.message, | ||
type: this.type, | ||
stack: this.stack, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TspSyncConfig { | ||
TSP_SYNC_SCHOOL_LIMIT: number; | ||
TSP_SYNC_SCHOOL_DAYS_TO_FETCH: number; | ||
} |
Oops, something went wrong.