-
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
BC-7466 - Switch SHD administration of schools (students) to new deletion routines #5478
base: main
Are you sure you want to change the base?
Conversation
…nto BC-7466-shd-new-deletion-routines-for-students
apps/server/src/modules/deletion/api/controller/deletion-batch.controller.ts
Fixed
Show fixed
Hide fixed
const validUserIds: EntityId[] = []; | ||
const invalidUserIds: EntityId[] = []; | ||
|
||
for (const userId of targetRefIds) { |
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.
could be rewritten using a map, and then Promise.all
const invalidUserIds: EntityId[] = []; | ||
|
||
for (const userId of targetRefIds) { | ||
const userExists = await this.userRepo.findByIdOrNull(userId); |
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.
I am wondering why is even possible...but we should not be able to access user repo directly. It should be accessed via a service which user module exports.
public async createDeletionBatch( | ||
params: CreateDeletionBatchParams, | ||
validUserIds: EntityId[], | ||
invalidUserIds: EntityId[] | undefined |
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.
invalidUserIds: EntityId[] | undefined | |
invalidUserIds?: EntityId[] |
} | ||
|
||
// TODO implement as join on deletionbatches.targetRefIds to avoid N+1 | ||
public async getUsersByRoles(userIds: EntityId[]): Promise<UsersByRole[]> { |
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.
should be private
for (const targetRefId of batch.targetRefIds) { | ||
const deleteNow = new Date(Date.now()); | ||
await this.deletionRequestService.createDeletionRequest(targetRefId, DomainName.USER, deleteNow); | ||
} |
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.
for (const targetRefId of batch.targetRefIds) { | |
const deleteNow = new Date(Date.now()); | |
await this.deletionRequestService.createDeletionRequest(targetRefId, DomainName.USER, deleteNow); | |
} | |
const deleteNow = new Date(); | |
const deletionRequests = batch.targetRefIds.map(targetRefId => this.deletionRequestService.createDeletionRequest(targetRefId, DomainName.USER, deleteNow) | |
); | |
await Promise.all(deletionRequests); |
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.
on a second thought, this Promise.all might not be a good idea
Because it can be that we try to create a deletion request for a user id which already exists, in which case we should get an exception. And promise.all would stop
} | ||
|
||
public async createDeletionRequestForBatch(batchId: EntityId): Promise<DeletionBatchSummary> { | ||
const deletionBatch = await this.deletionBatchRepo.findById(batchId); |
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.
we should not access repo directly in the uc, but via service...
a simple wrapper function in service should do
], | ||
exports: [DeletionRequestService, DeletionLogService], | ||
exports: [DeletionRequestService, DeletionLogService, DeletionBatchService, DeletionBatchRepo], |
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.
Repo does not belong here... is needed because is injected in the uc, but there we should also not access the repo directly, but instead access the service
constructor( | ||
private readonly deletionBatchService: DeletionBatchService, | ||
private readonly deletionBatchRepo: DeletionBatchRepo, | ||
private readonly userRepo: UserRepo |
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.
repo should not be accessed directly in uc
Description
Switch SHD administration of schools (students) to new deletion routines
Links to Tickets or other pull requests
BC-7466
hpi-schul-cloud/superhero-dashboard#278
Approval for review
generate-client:server
was executed in vue frontend and changes were tested and put in a PR with the same branch name.