-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EW-1006: Add school part to TSP sync. #5279
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d74dc3a
Add school part to sync.
mkreuzkam-cap fe7dd8c
Merge branch 'main' into EW-1006
mkreuzkam-cap f3265dc
use client
mkreuzkam-cap 96ef010
fix dependencies and schema json
alweber-cap bd30949
work on school sync
mkreuzkam-cap 64eb815
Merge branch 'main' into EW-1006
mkreuzkam-cap 1bf0dbb
Add tests.
mkreuzkam-cap 5d1e29c
only import rabbitmq for tsp.
mkreuzkam-cap 89b4049
Merge branch 'main' into EW-1006
mkreuzkam-cap 8221d2a
Code review comments.
mkreuzkam-cap ee24fc2
Merge branch 'main' into EW-1006
mkreuzkam-cap c1a5ab1
code review
mkreuzkam-cap a1a059f
code review.
mkreuzkam-cap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
import { TspSchulnummerMissingLoggable } from './tsp-schulnummer-missing.loggable'; | ||
|
||
describe(TspSchulnummerMissingLoggable.name, () => { | ||
let loggable: TspSchulnummerMissingLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSchulnummerMissingLoggable(); | ||
}); | ||
|
||
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: `A TSP school is missing a Schulnummer. Skipping school.`, | ||
}); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
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,11 @@ | ||||||
import { Loggable, LogMessage } from '@src/core/logger'; | ||||||
|
||||||
export class TspSchulnummerMissingLoggable implements Loggable { | ||||||
getLogMessage(): LogMessage { | ||||||
const message: LogMessage = { | ||||||
message: `A TSP school is missing a Schulnummer. Skipping school.`, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
|
||||||
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, | ||
Fshmit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not very intuitive or expandable easily. But we have no other use for this currently, so it is ok