-
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.
Browse files
Browse the repository at this point in the history
* Add school data to TSP sync. --------- Co-authored-by: Alexander Weber <[email protected]>
- Loading branch information
1 parent
d567a04
commit 73165ca
Showing
19 changed files
with
941 additions
and
43 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
29 changes: 29 additions & 0 deletions
29
apps/server/src/infra/sync/tsp/loggable/tsp-data-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,29 @@ | ||
import { TspDataFetchedLoggable } from './tsp-data-fetched.loggable'; | ||
|
||
describe(TspDataFetchedLoggable.name, () => { | ||
let loggable: TspDataFetchedLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspDataFetchedLoggable(1, 2, 3, 4); | ||
}); | ||
|
||
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 1 teachers, 2 students and 3 classes for the last 4 days from TSP`, | ||
data: { | ||
tspTeacherCount: 1, | ||
tspStudentCount: 2, | ||
tspClassesCount: 3, | ||
daysFetched: 4, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
apps/server/src/infra/sync/tsp/loggable/tsp-data-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,24 @@ | ||
import { Loggable, LogMessage } from '@src/core/logger'; | ||
|
||
export class TspDataFetchedLoggable implements Loggable { | ||
constructor( | ||
private readonly tspTeacherCount: number, | ||
private readonly tspStudentCount: number, | ||
private readonly tspClassesCount: number, | ||
private readonly daysFetched: number | ||
) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `Fetched ${this.tspTeacherCount} teachers, ${this.tspStudentCount} students and ${this.tspClassesCount} classes for the last ${this.daysFetched} days from TSP`, | ||
data: { | ||
tspTeacherCount: this.tspTeacherCount, | ||
tspStudentCount: this.tspStudentCount, | ||
tspClassesCount: this.tspClassesCount, | ||
daysFetched: this.daysFetched, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/server/src/infra/sync/tsp/loggable/tsp-missing-external-id.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 { TspMissingExternalIdLoggable } from './tsp-missing-external-id.loggable'; | ||
|
||
describe(TspMissingExternalIdLoggable.name, () => { | ||
let loggable: TspMissingExternalIdLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspMissingExternalIdLoggable('teacher'); | ||
}); | ||
|
||
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 teacher is missing an id. It is skipped.`, | ||
data: { | ||
objectType: 'teacher', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
apps/server/src/infra/sync/tsp/loggable/tsp-missing-external-id.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 TspMissingExternalIdLoggable implements Loggable { | ||
constructor(private readonly objectType: string) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `A ${this.objectType} is missing an id. It is skipped.`, | ||
data: { | ||
objectType: this.objectType, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/server/src/infra/sync/tsp/loggable/tsp-synced-users.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 { TspSyncedUsersLoggable } from './tsp-synced-users.loggable'; | ||
|
||
describe(TspSyncedUsersLoggable.name, () => { | ||
let loggable: TspSyncedUsersLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSyncedUsersLoggable(10); | ||
}); | ||
|
||
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 10 users from TSP.`, | ||
data: { | ||
syncedUsers: 10, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
apps/server/src/infra/sync/tsp/loggable/tsp-synced-users.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 TspSyncedUsersLoggable implements Loggable { | ||
constructor(private readonly syncedUsers: number) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `Synced ${this.syncedUsers} users from TSP.`, | ||
data: { | ||
syncedUsers: this.syncedUsers, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/server/src/infra/sync/tsp/loggable/tsp-syncing-users.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 { TspSyncingUsersLoggable } from './tsp-syncing-users.loggable'; | ||
|
||
describe(TspSyncingUsersLoggable.name, () => { | ||
let loggable: TspSyncingUsersLoggable; | ||
|
||
beforeAll(() => { | ||
loggable = new TspSyncingUsersLoggable(10); | ||
}); | ||
|
||
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: `Syncing 10 users from TSP.`, | ||
data: { | ||
syncingUsers: 10, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
apps/server/src/infra/sync/tsp/loggable/tsp-syncing-users.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 TspSyncingUsersLoggable implements Loggable { | ||
constructor(private readonly syncingUsers: number) {} | ||
|
||
getLogMessage(): LogMessage { | ||
const message: LogMessage = { | ||
message: `Syncing ${this.syncingUsers} users from TSP.`, | ||
data: { | ||
syncingUsers: this.syncingUsers, | ||
}, | ||
}; | ||
|
||
return message; | ||
} | ||
} |
Oops, something went wrong.