diff --git a/controllers/orderController.go b/controllers/orderController.go index dadc081..6bc6fa0 100644 --- a/controllers/orderController.go +++ b/controllers/orderController.go @@ -401,6 +401,12 @@ func CreateOrder(c *fiber.Ctx) error { }) } + // ✅ Fallback if deliverytime is missing - it maps to a `timestamp` column, + // so an empty string (the zero value) is rejected by Postgres outright. + if strings.TrimSpace(data.Deliverytime) == "" { + data.Deliverytime = time.Now().Format("2006-01-02 15:04:05") + } + // ✅ Fallback if orderdate is missing if strings.TrimSpace(data.Orderdate) == "" { data.Orderdate = time.Now().Format("2006-01-02 15:04:05") diff --git a/domain/partner.go b/domain/partner.go index 05a7783..c85772b 100644 --- a/domain/partner.go +++ b/domain/partner.go @@ -1053,7 +1053,9 @@ func UpdateRiderLogv1(data models.Riderlogs) error { ctx := context.Background() key := "riderlogs" - logs, err := db.Rdb.LRange(ctx, key, 0, -1).Result() + // See comment in GetRiderLogsv1: riderlogs is an unbounded list, full scans + // need more than the client's default 3s ReadTimeout. + logs, err := db.Rdb.WithTimeout(15 * time.Second).LRange(ctx, key, 0, -1).Result() if err != nil { return errors.New("failed to fetch logs from redis: " + err.Error()) } @@ -1156,7 +1158,11 @@ func GetRiderLogsv1(fromdate, todate, keyword string, partnerid int) ([]models.R ctx := context.Background() results := []models.Riderlogsv1{} - redisList, err := db.Rdb.LRange(ctx, "riderlogs", 0, -1).Result() + // riderlogs is an unbounded, ever-growing list (900K+ entries as of writing). + // A full-list LRANGE routinely takes several seconds, well past the client's + // default 3s ReadTimeout, so this call gets a longer timeout scoped to just + // this request instead of loosening the timeout for every Redis call. + redisList, err := db.Rdb.WithTimeout(15 * time.Second).LRange(ctx, "riderlogs", 0, -1).Result() if err != nil { return nil, errors.New("redis lrange error: " + err.Error()) }