Skip to content

Commit

Permalink
🩹 fix simple bug in lent and return #114
Browse files Browse the repository at this point in the history
fix simple bug in lent and return #114
  • Loading branch information
sichoi42 committed Nov 6, 2022
1 parent 1676933 commit cb92b36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
1 change: 0 additions & 1 deletion backend/src/v3/lent/lent.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class LentTools {
);
}
await this.lentRepository.setExpireTimeAll(cabinet_id, expire_time);
runOnTransactionComplete((err) => err && this.logger.error(err));
}

@Transactional({
Expand Down
27 changes: 11 additions & 16 deletions backend/src/v3/return/return.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,30 @@ export class ReturnService {

async returnBundle(users: number[], cabinets: number[]): Promise<void> {
this.logger.debug(`Called ${ReturnService.name} ${this.returnBundle.name}`);
const user_failures = []
const cabinets_failures = []
if (users) {
const failures = []
for await (const user_id of users) {
await this.returnUserCabinet(user_id)
.catch(() => {
failures.push(user_id);
user_failures.push(user_id);
})
}
if (failures.length !== 0) {
throw new HttpException(
{ "user_failures": failures },
HttpStatus.BAD_REQUEST,
);
}
}
if (cabinets) {
const failures = []
for await (const cabinet_id of cabinets) {
await this.returnCabinet(cabinet_id)
.catch(() => {
failures.push(cabinet_id);
cabinets_failures.push(cabinet_id);
})
}
if (failures.length !== 0) {
throw new HttpException(
{ "cabinet_failures": failures },
HttpStatus.BAD_REQUEST,
);
}
}
if (!(user_failures.length === 0 && cabinets_failures.length === 0)) {
throw new HttpException({
"user_failures": user_failures,
"cabinet_failures": cabinets_failures,
}, HttpStatus.BAD_REQUEST,
);
}
}
}

0 comments on commit cb92b36

Please sign in to comment.