From 692c5f9edc68496421b269d17f10ec8f82b71ea1 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 12 Jul 2023 11:52:02 +0100 Subject: [PATCH] Fix: operations.Last --- internal/postgres/operation/storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/postgres/operation/storage.go b/internal/postgres/operation/storage.go index 3ec6618a7..43057f856 100644 --- a/internal/postgres/operation/storage.go +++ b/internal/postgres/operation/storage.go @@ -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") @@ -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).