From 655ac3e8fb83e1cb9b670ab420a0f661dc19786e Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 27 Apr 2022 14:53:11 +0100 Subject: [PATCH] Try that again --- syncapi/storage/postgres/account_data_table.go | 10 ++++------ syncapi/storage/sqlite3/account_data_table.go | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/syncapi/storage/postgres/account_data_table.go b/syncapi/storage/postgres/account_data_table.go index 7c0d0303..e9c72058 100644 --- a/syncapi/storage/postgres/account_data_table.go +++ b/syncapi/storage/postgres/account_data_table.go @@ -105,7 +105,6 @@ func (s *accountDataStatements) SelectAccountDataInRange( accountDataEventFilter *gomatrixserverlib.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { data = make(map[string][]string) - pos = r.High() rows, err := s.selectAccountDataInRangeStmt.QueryContext(ctx, userID, r.Low(), r.High(), pq.StringArray(filterConvertTypeWildcardToSQL(accountDataEventFilter.Types)), @@ -120,7 +119,6 @@ func (s *accountDataStatements) SelectAccountDataInRange( var dataType string var roomID string var id types.StreamPosition - var highest types.StreamPosition for rows.Next() { if err = rows.Scan(&id, &roomID, &dataType); err != nil { @@ -132,12 +130,12 @@ func (s *accountDataStatements) SelectAccountDataInRange( } else { data[roomID] = []string{dataType} } - if id > highest { - highest = id + if id > pos { + pos = id } } - if highest < pos { - pos = highest + if pos == 0 { + pos = r.High() } return data, pos, rows.Err() } diff --git a/syncapi/storage/sqlite3/account_data_table.go b/syncapi/storage/sqlite3/account_data_table.go index 1bbfe9c9..21a16dcd 100644 --- a/syncapi/storage/sqlite3/account_data_table.go +++ b/syncapi/storage/sqlite3/account_data_table.go @@ -96,7 +96,6 @@ func (s *accountDataStatements) SelectAccountDataInRange( r types.Range, filter *gomatrixserverlib.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { - pos = r.High() data = make(map[string][]string) stmt, params, err := prepareWithFilters( s.db, nil, selectAccountDataInRangeSQL, @@ -116,7 +115,6 @@ func (s *accountDataStatements) SelectAccountDataInRange( var dataType string var roomID string var id types.StreamPosition - var highest types.StreamPosition for rows.Next() { if err = rows.Scan(&id, &roomID, &dataType); err != nil { @@ -128,12 +126,12 @@ func (s *accountDataStatements) SelectAccountDataInRange( } else { data[roomID] = []string{dataType} } - if id > highest { - highest = id + if id > pos { + pos = id } } - if highest < pos { - pos = highest + if pos == 0 { + pos = r.High() } return data, pos, nil }