Skip to content

Commit

Permalink
fix: s/Cursor/IdCursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Jan 12, 2024
1 parent d0f3294 commit 9c76ef4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/uptrace/bun/driver/pgdriver v1.1.16
github.com/waku-org/go-waku v0.8.0
github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3
github.com/xmtp/proto/v3 v3.36.3-0.20240111234026-aeee9aeb6f6a
github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9
github.com/yoheimuta/protolint v0.39.0
go.uber.org/zap v1.24.0
golang.org/x/sync v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,8 @@ github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3 h1:wzUffJGCTBGXIDyNU+1UBu1fn2Nzo+OQzM1pLrheh58=
github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3/go.mod h1:bJREWk+NDnZYjgLQdAi8SUWuq/5pkMme4GqiffEhUF4=
github.com/xmtp/proto/v3 v3.36.3-0.20240111234026-aeee9aeb6f6a h1:UPMdphzbD38Ypgsr00QtHQRDkC5NFuVXH4pZiWCv/MM=
github.com/xmtp/proto/v3 v3.36.3-0.20240111234026-aeee9aeb6f6a/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY=
github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9 h1:iWIW7/LCIej+Aof/RglSUKU/+bIv1vFpD4vyOwQz4PY=
github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/yoheimuta/go-protoparser/v4 v4.6.0 h1:uvz1e9/5Ihsm4Ku8AJeDImTpirKmIxubZdSn0QJNdnw=
github.com/yoheimuta/go-protoparser/v4 v4.6.0/go.mod h1:AHNNnSWnb0UoL4QgHPiOAg2BniQceFscPI5X/BZNHl8=
Expand Down
20 changes: 10 additions & 10 deletions pkg/mls/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ func (s *Store) QueryGroupMessagesV1(ctx context.Context, req *mlsv1.QueryGroupM
}
q = q.Limit(pageSize)

if req.PagingInfo != nil && req.PagingInfo.Cursor != 0 {
if req.PagingInfo != nil && req.PagingInfo.IdCursor != 0 {
if direction == mlsv1.SortDirection_SORT_DIRECTION_ASCENDING {
q = q.Where("id > ?", req.PagingInfo.Cursor)
q = q.Where("id > ?", req.PagingInfo.IdCursor)
} else {
q = q.Where("id < ?", req.PagingInfo.Cursor)
q = q.Where("id < ?", req.PagingInfo.IdCursor)
}
}

Expand All @@ -271,11 +271,11 @@ func (s *Store) QueryGroupMessagesV1(ctx context.Context, req *mlsv1.QueryGroupM
})
}

pagingInfo := &mlsv1.PagingInfo{Limit: 0, Cursor: 0, Direction: direction}
pagingInfo := &mlsv1.PagingInfo{Limit: 0, IdCursor: 0, Direction: direction}
if len(messages) >= pageSize {
if len(messages) > 0 {
lastMsg := msgs[len(messages)-1]
pagingInfo.Cursor = lastMsg.Id
pagingInfo.IdCursor = lastMsg.Id
}
}

Expand Down Expand Up @@ -313,11 +313,11 @@ func (s *Store) QueryWelcomeMessagesV1(ctx context.Context, req *mlsv1.QueryWelc
}
q = q.Limit(pageSize)

if req.PagingInfo != nil && req.PagingInfo.Cursor != 0 {
if req.PagingInfo != nil && req.PagingInfo.IdCursor != 0 {
if direction == mlsv1.SortDirection_SORT_DIRECTION_ASCENDING {
q = q.Where("id > ?", req.PagingInfo.Cursor)
q = q.Where("id > ?", req.PagingInfo.IdCursor)
} else {
q = q.Where("id < ?", req.PagingInfo.Cursor)
q = q.Where("id < ?", req.PagingInfo.IdCursor)
}
}

Expand All @@ -339,11 +339,11 @@ func (s *Store) QueryWelcomeMessagesV1(ctx context.Context, req *mlsv1.QueryWelc
})
}

pagingInfo := &mlsv1.PagingInfo{Limit: 0, Cursor: 0, Direction: direction}
pagingInfo := &mlsv1.PagingInfo{Limit: 0, IdCursor: 0, Direction: direction}
if len(messages) >= pageSize {
if len(messages) > 0 {
lastMsg := msgs[len(messages)-1]
pagingInfo.Cursor = lastMsg.Id
pagingInfo.IdCursor = lastMsg.Id
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/mls/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ func TestQueryGroupMessagesV1_Paginate(t *testing.T) {
resp, err = store.QueryGroupMessagesV1(ctx, &mlsv1.QueryGroupMessagesRequest{
GroupId: []byte("group1"),
PagingInfo: &mlsv1.PagingInfo{
Limit: 2,
Cursor: thirdMsg.GetV1().Id,
Limit: 2,
IdCursor: thirdMsg.GetV1().Id,
},
})
require.NoError(t, err)
Expand All @@ -478,7 +478,7 @@ func TestQueryGroupMessagesV1_Paginate(t *testing.T) {
PagingInfo: &mlsv1.PagingInfo{
Limit: 2,
Direction: mlsv1.SortDirection_SORT_DIRECTION_ASCENDING,
Cursor: fifthMsg.GetV1().Id,
IdCursor: fifthMsg.GetV1().Id,
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -549,8 +549,8 @@ func TestQueryWelcomeMessagesV1_Paginate(t *testing.T) {
resp, err = store.QueryWelcomeMessagesV1(ctx, &mlsv1.QueryWelcomeMessagesRequest{
InstallationId: []byte("installation1"),
PagingInfo: &mlsv1.PagingInfo{
Limit: 2,
Cursor: thirdMsg.GetV1().Id,
Limit: 2,
IdCursor: thirdMsg.GetV1().Id,
},
})
require.NoError(t, err)
Expand All @@ -573,7 +573,7 @@ func TestQueryWelcomeMessagesV1_Paginate(t *testing.T) {
PagingInfo: &mlsv1.PagingInfo{
Limit: 2,
Direction: mlsv1.SortDirection_SORT_DIRECTION_ASCENDING,
Cursor: fifthMsg.GetV1().Id,
IdCursor: fifthMsg.GetV1().Id,
},
})
require.NoError(t, err)
Expand Down

0 comments on commit 9c76ef4

Please sign in to comment.