彻底优化数据库字段
This commit is contained in:
@@ -298,10 +298,7 @@ func (j *Job) handleReturnOverdue(ctx context.Context, now time.Time, cfg thresh
|
||||
var rows []model.RentalOrder
|
||||
overdueBefore := now.Add(-time.Duration(cfg.ReturnOverdueGraceMinutes) * time.Minute)
|
||||
err := j.db.WithContext(ctx).
|
||||
Where(`status = ? AND (
|
||||
(rented_at IS NOT NULL AND TIMESTAMPADD(HOUR, COALESCE(NULLIF(estimated_duration_hours, 0), 24), rented_at) <= ?)
|
||||
OR (rented_at IS NULL AND rent_end_at IS NOT NULL AND rent_end_at <= ?)
|
||||
)`, "renting", overdueBefore, overdueBefore).
|
||||
Where(`status = ? AND rented_at IS NOT NULL AND TIMESTAMPADD(HOUR, COALESCE(NULLIF(estimated_duration_hours, 0), 24), rented_at) <= ?`, "renting", overdueBefore).
|
||||
Order("id ASC").
|
||||
Limit(100).
|
||||
Find(&rows).Error
|
||||
|
||||
Reference in New Issue
Block a user