How bad is this code?
This is something i found in prod, should this be refactored?
// ** Items.
for (
const
item of updateItems) {
await this._itemRepository.update(item);
}
for (
const
item of newItemHistory) {
const
newHistory = await this._itemHistoryRepository.create(item);
savedItemHistory.push(newHistory);
}
for (
const
item of newItemsLogs) {
await this._itemLogRepository.create(item);
}
// ** Bins.
for (
const
bin of updateBins) {
await this._binRepository.update(bin);
}
for (
const
bin of binLogs) {
await this._binLogRepository.create(bin);
}
for (
const
bin of binsHistory) {
const
newHistory = await this._binHistoryRepository.create(bin);
newBinsHistory.push(newHistory);
}
// ** Racks.
await this._rackRepository.updateMultiple(updateRacks);
await this._rackLogRepository.createMultiple(racksLogs);
newRacksHistory = await this._rackHistoryRepository.createMultiple(racksHistory);
}
if (unitIds || isOverpackingUnit) {
// ** Unit.
for (
const
unit of updateUnits) {
await this._unitRepository.update(unit);
}
for (
const
unit of unitHistory) {
const
newHistory = await this._unitHistoryRepository.create(unit);
newUnitHistory.push(newHistory);
}
for (
const
unit of newUnitLogs) {
await this._itemLogRepository.create(unit);
}
}