From e2d10b92d150981283108f7ab23047a619c10314 Mon Sep 17 00:00:00 2001 From: Maxim Ivanchenko Date: Thu, 11 Jul 2024 15:23:39 +0300 Subject: [PATCH] EPMUII-7929 follow suggestions in review --- internal/repositories/equipment.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/repositories/equipment.go b/internal/repositories/equipment.go index 54d5172..c06025e 100644 --- a/internal/repositories/equipment.go +++ b/internal/repositories/equipment.go @@ -3,6 +3,7 @@ package repositories import ( "context" "errors" + "fmt" "time" "entgo.io/ent/dialect/sql" @@ -516,6 +517,7 @@ func (r *equipmentRepository) BlockEquipment( return err } + timeNow := time.Now() // Get EquipmentStatusName for "not available" from DB. eqStatusNotAvailable, err := tx.EquipmentStatusName. Query(). @@ -525,8 +527,8 @@ func (r *equipmentRepository) BlockEquipment( return err } - // Get (if exists) EqupmentStatus for current Equipment. - // Note, that only one row with "not available" stauts may exist per single equipment id. + // Get (if exists) EquipmentStatus for current Equipment. + // Note, that only one row with "not available" status may exist per single equipment id. eqToBlockStatus, err := tx.EquipmentStatus. Query(). QueryEquipments(). @@ -543,16 +545,16 @@ func (r *equipmentRepository) BlockEquipment( Update(). SetStartDate(startDate). SetEndDate(endDate). - SetUpdatedAt(time.Now()). + SetUpdatedAt(timeNow). Save(ctx) } else if ent.IsNotFound(err) { _, err = tx.EquipmentStatus.Create(). - SetCreatedAt(time.Now()). + SetCreatedAt(timeNow). SetEndDate(endDate). SetStartDate(startDate). SetEquipments(eqToBlock). SetEquipmentStatusName(eqStatusNotAvailable). - SetUpdatedAt(time.Now()). + SetUpdatedAt(timeNow). Save(ctx) if err != nil { return err