Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PostComments paginated query method #510

Merged
merged 29 commits into from Jun 25, 2021
Merged

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Jun 22, 2021

Description

This PR is the implementation of #505.
Closes #505

  • Remove CommentID object from proto
  • Add PostComments query method
  • Add PostComments cmd function

Checklist

  • Targeted PR against correct branch.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit tests.
  • Wrote integration tests (simulation & CLI).
  • Updated the documentation.
  • Added an entry to the CHANGELOG.md file.
  • Re-reviewed Files changed in the Github PR explorer.

@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #510 (73e37f9) into master (504d24e) will decrease coverage by 0.00%.
The diff coverage is 93.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #510      +/-   ##
==========================================
- Coverage   84.94%   84.93%   -0.01%     
==========================================
  Files          89       89              
  Lines        4284     4296      +12     
==========================================
+ Hits         3639     3649      +10     
- Misses        484      485       +1     
- Partials      161      162       +1     
Impacted Files Coverage Δ
x/staging/posts/types/posts.go 89.61% <ø> (-0.39%) ⬇️
x/staging/posts/keeper/grpc_query.go 79.26% <88.88%> (+2.70%) ⬆️
x/staging/posts/keeper/keeper.go 100.00% <100.00%> (ø)
x/staging/posts/keeper/msgs_server.go 87.31% <100.00%> (+0.18%) ⬆️
x/staging/posts/simulation/decoder.go 93.10% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 504d24e...73e37f9. Read the comment docs.

@dadamu dadamu marked this pull request as ready for review June 23, 2021 09:05
x/staging/posts/keeper/keeper.go Outdated Show resolved Hide resolved
x/staging/posts/keeper/keeper.go Outdated Show resolved Hide resolved
x/staging/posts/keeper/msgs_server_test.go Show resolved Hide resolved
x/staging/posts/keeper/msgs_server_test.go Outdated Show resolved Hide resolved
x/staging/posts/simulation/decoder.go Show resolved Hide resolved
dadamu and others added 4 commits June 24, 2021 00:46
@dadamu dadamu requested a review from leobragaz June 23, 2021 23:25
@@ -93,6 +93,11 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest,
"post with id %s does not allow comments", parentPost.PostID)
}

if parentPost.Subspace != post.Subspace {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

// nolint: interfacer
func (k Keeper) GetPostChildrenIDs(ctx sdk.Context, postID string) []string {
store := ctx.KVStore(k.storeKey)
func (k Keeper) GetPostCommentsIDs(ctx sdk.Context, postID string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time understanding where this is used. Maybe we can delete it?

Copy link
Contributor Author

@dadamu dadamu Jun 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It is only for test. Let me move it to test files or use another way in test.

@@ -30,6 +30,23 @@ func (k Keeper) IteratePosts(ctx sdk.Context, fn func(index int64, post types.Po
}
}

func (k Keeper) IterateCommentIDsByPost(ctx sdk.Context, postID string, fn func(index int64, commentID string) (stop bool)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only used inside GetPostCommentsIDs, which appears to be unused as well. Maybe we can delete this as well?

@dadamu dadamu requested a review from RiccardoM June 25, 2021 08:12
@RiccardoM RiccardoM enabled auto-merge (squash) June 25, 2021 08:17
Copy link
Contributor

@leobragaz leobragaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@RiccardoM RiccardoM merged commit 5a369d1 into master Jun 25, 2021
@RiccardoM RiccardoM deleted the paul/add-post-comments-query branch June 25, 2021 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GetPostComments paginated query method
3 participants