Skip to content

Commit

Permalink
Fix: operations.Last
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 12, 2023
1 parent faa11df commit 692c5f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/postgres/operation/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (storage *Storage) Last(filters map[string]interface{}, lastID int64) (oper
}
}

for current.Before(endTime) {
for current.After(endTime) {
query := storage.DB.Model((*operation.Operation)(nil)).
Where("deffated_storage is not null").
OrderExpr("operation.id desc")
Expand All @@ -172,7 +172,7 @@ func (storage *Storage) Last(filters map[string]interface{}, lastID int64) (oper
query.Where("operation.id < ?", lastID)
}

query.Limit(2) // It's a hack to avoid postgres "optimization". Limit = 1 is extremely slow.
query.Limit(1)

var ops []operation.Operation
if err := storage.DB.Model().TableExpr("(?) as operation", query).
Expand Down

0 comments on commit 692c5f9

Please sign in to comment.