diff --git a/common/persistence/sql/sql_domain_audit_store.go b/common/persistence/sql/sql_domain_audit_store.go index 0a1b1b3c421..f9033f5a4a1 100644 --- a/common/persistence/sql/sql_domain_audit_store.go +++ b/common/persistence/sql/sql_domain_audit_store.go @@ -119,7 +119,6 @@ func (m *sqlDomainAuditStore) GetDomainAuditLogs( DomainID: request.DomainID, OperationType: request.OperationType, MinCreatedTime: &minCreatedTime, - MaxCreatedTime: &maxCreatedTime, PageSize: request.PageSize, PageMaxCreatedTime: &pageMaxCreatedTime, PageMinEventID: &pageMinEventID, diff --git a/common/persistence/sql/sql_domain_audit_store_test.go b/common/persistence/sql/sql_domain_audit_store_test.go index 017e6e6be9c..1ff4e5546e6 100644 --- a/common/persistence/sql/sql_domain_audit_store_test.go +++ b/common/persistence/sql/sql_domain_audit_store_test.go @@ -226,7 +226,6 @@ func TestGetDomainAuditLogs(t *testing.T) { DomainID: "d1111111-1111-1111-1111-111111111111", OperationType: persistence.DomainAuditOperationTypeUpdate, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageSize: pageSize, PageMaxCreatedTime: &maxTime, PageMinEventID: &maxUUID, @@ -302,7 +301,6 @@ func TestGetDomainAuditLogs(t *testing.T) { DomainID: "d1111111-1111-1111-1111-111111111111", OperationType: persistence.DomainAuditOperationTypeUpdate, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageSize: pageSize2, PageMaxCreatedTime: &expectedCreatedTime, PageMinEventID: &expectedEventID, diff --git a/common/persistence/sql/sqlplugin/interfaces.go b/common/persistence/sql/sqlplugin/interfaces.go index 3ff3d71c248..fba18694e26 100644 --- a/common/persistence/sql/sqlplugin/interfaces.go +++ b/common/persistence/sql/sqlplugin/interfaces.go @@ -604,7 +604,6 @@ type ( DomainID string OperationType persistence.DomainAuditOperationType MinCreatedTime *time.Time - MaxCreatedTime *time.Time PageSize int // PageMaxCreatedTime and PageMinEventID are used to paginate Select queries PageMaxCreatedTime *time.Time diff --git a/common/persistence/sql/sqlplugin/postgres/domain_audit_log.go b/common/persistence/sql/sqlplugin/postgres/domain_audit_log.go index 5f92b704154..a27186a83c5 100644 --- a/common/persistence/sql/sqlplugin/postgres/domain_audit_log.go +++ b/common/persistence/sql/sqlplugin/postgres/domain_audit_log.go @@ -37,16 +37,16 @@ const ( event_id, domain_id, state_before, state_before_encoding, state_after, state_after_encoding, operation_type, created_time, last_updated_time, identity, identity_type, comment FROM domain_audit_log - WHERE domain_id = $1 AND operation_type = $2 AND created_time >= $3 AND created_time < $4 - AND (created_time < $5 OR (created_time = $5 AND event_id > $6)) + WHERE domain_id = $1 AND operation_type = $2 AND created_time >= $3 + AND (created_time < $4 OR (created_time = $4 AND event_id > $5)) ORDER BY created_time DESC, event_id ASC - LIMIT $7` + LIMIT $6` _selectAllDomainAuditLogsQuery = `SELECT event_id, domain_id, state_before, state_before_encoding, state_after, state_after_encoding, operation_type, created_time, last_updated_time, identity, identity_type, comment FROM domain_audit_log - WHERE domain_id = $1 AND operation_type = $2 AND created_time >= $3 AND created_time < $4 - AND (created_time < $5 OR (created_time = $5 AND event_id > $6)) + WHERE domain_id = $1 AND operation_type = $2 AND created_time >= $3 + AND (created_time < $4 OR (created_time = $4 AND event_id > $5)) ORDER BY created_time DESC, event_id ASC` ) @@ -80,7 +80,6 @@ func (pdb *db) SelectFromDomainAuditLogs( filter.DomainID, filter.OperationType, *filter.MinCreatedTime, - *filter.MaxCreatedTime, *filter.PageMaxCreatedTime, *filter.PageMinEventID, } diff --git a/common/persistence/sql/sqlplugin/postgres/domain_audit_log_test.go b/common/persistence/sql/sqlplugin/postgres/domain_audit_log_test.go index bd1b5b10ef6..c75ddaf2c2b 100644 --- a/common/persistence/sql/sqlplugin/postgres/domain_audit_log_test.go +++ b/common/persistence/sql/sqlplugin/postgres/domain_audit_log_test.go @@ -171,7 +171,6 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { DomainID: domainID, OperationType: operationType, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageSize: 2, PageMaxCreatedTime: &defaultPageMaxCreatedTime, PageMinEventID: &defaultPageMinEventID, @@ -182,7 +181,7 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { sqlplugin.DbDefaultShard, gomock.Any(), _selectDomainAuditLogsQuery, - domainID, operationType, minTime, maxTime, defaultPageMaxCreatedTime, defaultPageMinEventID, 2, + domainID, operationType, minTime, defaultPageMaxCreatedTime, defaultPageMinEventID, 2, ).DoAndReturn(func(ctx context.Context, shardID int, dest interface{}, query string, args ...interface{}) error { rows := dest.(*[]*sqlplugin.DomainAuditLogRow) *rows = []*sqlplugin.DomainAuditLogRow{ @@ -224,7 +223,6 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { DomainID: domainID, OperationType: operationType, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageSize: 0, PageMaxCreatedTime: &createdTime2, PageMinEventID: &eventID2, @@ -235,7 +233,7 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { sqlplugin.DbDefaultShard, gomock.Any(), _selectAllDomainAuditLogsQuery, - domainID, operationType, minTime, maxTime, createdTime2, eventID2, + domainID, operationType, minTime, createdTime2, eventID2, ).DoAndReturn(func(ctx context.Context, shardID int, dest interface{}, query string, args ...interface{}) error { rows := dest.(*[]*sqlplugin.DomainAuditLogRow) *rows = []*sqlplugin.DomainAuditLogRow{ @@ -277,7 +275,6 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { DomainID: domainID, OperationType: operationType, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageMaxCreatedTime: &defaultPageMaxCreatedTime, PageMinEventID: &defaultPageMinEventID, }, @@ -287,7 +284,7 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { sqlplugin.DbDefaultShard, gomock.Any(), _selectAllDomainAuditLogsQuery, - domainID, operationType, minTime, maxTime, defaultPageMaxCreatedTime, defaultPageMinEventID, + domainID, operationType, minTime, defaultPageMaxCreatedTime, defaultPageMinEventID, ).DoAndReturn(func(ctx context.Context, shardID int, dest interface{}, query string, args ...interface{}) error { return nil }) @@ -301,7 +298,6 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { DomainID: domainID, OperationType: operationType, MinCreatedTime: &minTime, - MaxCreatedTime: &maxTime, PageMaxCreatedTime: &defaultPageMaxCreatedTime, PageMinEventID: &defaultPageMinEventID, }, @@ -311,7 +307,7 @@ func TestSelectFromDomainAuditLogs(t *testing.T) { sqlplugin.DbDefaultShard, gomock.Any(), _selectAllDomainAuditLogsQuery, - domainID, operationType, minTime, maxTime, defaultPageMaxCreatedTime, defaultPageMinEventID, + domainID, operationType, minTime, defaultPageMaxCreatedTime, defaultPageMinEventID, ).Return(errors.New("select failed")) }, wantRows: nil,