You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/02/12 09:51:37 UTC

[GitHub] [servicecomb-kie] GuoYL123 opened a new pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

GuoYL123 opened a new pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378635299
 
 

 ##########
 File path: pkg/model/kv.go
 ##########
 @@ -29,8 +29,8 @@ type KVRequest struct {
 //KVResponse represents the key value list
 type KVResponse struct {
 	LabelDoc *LabelDocResponse `json:"label,omitempty"`
-	PageNum  int               `json:"num,omitempty"`
-	Size     int               `json:"size,omitempty"`
+	PageNum  int64             `json:"num,omitempty"`
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang merged pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378635239
 
 

 ##########
 File path: server/service/mongo/history/dao.go
 ##########
 @@ -27,20 +27,22 @@ import (
 	"go.mongodb.org/mongo-driver/mongo/options"
 )
 
-func getHistoryByKeyID(ctx context.Context, filter bson.M, limit, offset int64) ([]*model.KVDoc, error) {
+func getHistoryByKeyID(ctx context.Context, filter bson.M, pageNum, pageSize int64) ([]*model.KVDoc, int, error) {
 	collection := session.GetDB().Collection(session.CollectionKVRevision)
 	opt := options.Find().SetSort(map[string]interface{}{
 		"revision": -1,
 	})
-	if limit != 0 {
-		opt = opt.SetLimit(limit)
+	if pageNum != 0 && pageSize != 0 {
+		opt = opt.SetLimit(pageSize)
+		opt = opt.SetSkip(pageSize * (pageNum - 1))
 	}
-	if offset != 0 {
-		opt = opt.SetSkip(offset)
+	curTotal, errTotal := collection.CountDocuments(ctx, filter)
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378602538
 
 

 ##########
 File path: server/service/mongo/kv/kv_dao.go
 ##########
 @@ -117,11 +117,19 @@ func findKV(ctx context.Context, domain string, project string, opts service.Fin
 		}
 	}
 	opt := options.Find()
-	if opts.Limit != 0 {
-		opt = opt.SetLimit(opts.Limit)
+	if opts.PageSize != 0 && opts.PageNum != 0 {
+		opt = opt.SetLimit(opts.PageSize)
+		opt = opt.SetSkip(opts.PageSize * (opts.PageNum - 1))
 	}
-	if opts.Offset != 0 {
-		opt = opt.SetSkip(opts.Offset)
+	curTotal, errTotal := collection.CountDocuments(ctx, filter)
 
 Review comment:
   这个err也是

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378602746
 
 

 ##########
 File path: pkg/model/kv.go
 ##########
 @@ -29,8 +29,8 @@ type KVRequest struct {
 //KVResponse represents the key value list
 type KVResponse struct {
 	LabelDoc *LabelDocResponse `json:"label,omitempty"`
-	PageNum  int               `json:"num,omitempty"`
-	Size     int               `json:"size,omitempty"`
+	PageNum  int64             `json:"num,omitempty"`
 
 Review comment:
   2个字段删了吧,没用,我加多了

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378635251
 
 

 ##########
 File path: server/service/mongo/kv/kv_dao.go
 ##########
 @@ -117,11 +117,19 @@ func findKV(ctx context.Context, domain string, project string, opts service.Fin
 		}
 	}
 	opt := options.Find()
-	if opts.Limit != 0 {
-		opt = opt.SetLimit(opts.Limit)
+	if opts.PageSize != 0 && opts.PageNum != 0 {
+		opt = opt.SetLimit(opts.PageSize)
+		opt = opt.SetSkip(opts.PageSize * (opts.PageNum - 1))
 	}
-	if opts.Offset != 0 {
-		opt = opt.SetSkip(opts.Offset)
+	curTotal, errTotal := collection.CountDocuments(ctx, filter)
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378602320
 
 

 ##########
 File path: server/service/mongo/history/dao.go
 ##########
 @@ -27,20 +27,22 @@ import (
 	"go.mongodb.org/mongo-driver/mongo/options"
 )
 
-func getHistoryByKeyID(ctx context.Context, filter bson.M, limit, offset int64) ([]*model.KVDoc, error) {
+func getHistoryByKeyID(ctx context.Context, filter bson.M, pageNum, pageSize int64) ([]*model.KVDoc, int, error) {
 	collection := session.GetDB().Collection(session.CollectionKVRevision)
 	opt := options.Find().SetSort(map[string]interface{}{
 		"revision": -1,
 	})
-	if limit != 0 {
-		opt = opt.SetLimit(limit)
+	if pageNum != 0 && pageSize != 0 {
+		opt = opt.SetLimit(pageSize)
+		opt = opt.SetSkip(pageSize * (pageNum - 1))
 	}
-	if offset != 0 {
-		opt = opt.SetSkip(offset)
+	curTotal, errTotal := collection.CountDocuments(ctx, filter)
 
 Review comment:
   errTotal 是没必要的,叫err就行了

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services