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

Allow to paginate post reactions #515

Merged
merged 30 commits into from
Jun 30, 2021
Merged

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Jun 24, 2021

Description

This PR is implementation of #504.
Close #504

  • Reconstructed PostReaction struct
  • Remove PostReactionEntry
  • Added PostReactions query

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 24, 2021

Codecov Report

Merging #515 (7d87b57) into master (a82f1ed) will increase coverage by 0.00%.
The diff coverage is 89.52%.

❗ Current head 7d87b57 differs from pull request most recent head a07edc3. Consider uploading reports for the commit a07edc3 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #515   +/-   ##
=======================================
  Coverage   81.62%   81.62%           
=======================================
  Files          91       91           
  Lines        4724     4741   +17     
=======================================
+ Hits         3856     3870   +14     
+ Misses        680      678    -2     
- Partials      188      193    +5     
Impacted Files Coverage Δ
x/staging/posts/keeper/genesis.go 92.85% <66.66%> (ø)
x/staging/posts/keeper/msgs_server.go 87.31% <75.00%> (ø)
x/staging/posts/keeper/common_functions.go 86.36% <77.77%> (-3.81%) ⬇️
x/staging/posts/keeper/grpc_query.go 80.80% <88.88%> (+1.53%) ⬆️
x/staging/posts/keeper/invariants.go 79.36% <100.00%> (ø)
x/staging/posts/keeper/keeper_reactions.go 100.00% <100.00%> (+3.50%) ⬆️
x/staging/posts/simulation/decoder.go 93.10% <100.00%> (ø)
x/staging/posts/types/genesis.go 100.00% <100.00%> (+22.58%) ⬆️
x/staging/posts/types/reactions.go 94.73% <100.00%> (-1.10%) ⬇️
x/staging/posts/types/utils.go 20.00% <0.00%> (-80.00%) ⬇️
... and 1 more

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 a82f1ed...a07edc3. Read the comment docs.

@RiccardoM RiccardoM changed the title Add PostReactions query method Allow to paginate post reactions Jun 25, 2021
@dadamu dadamu marked this pull request as ready for review June 25, 2021 11:32
Copy link
Contributor

@RiccardoM RiccardoM left a comment

Choose a reason for hiding this comment

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

Great job! 🚀 There are some minor things to tweak but otherwise looks very good.
I see that you also improved the registered reactions query, or am I wrong? Maybe it's worth adding a CHANGELOG entry for that one as well?

// GetCmdQueryPostReactions returns the command allowing to query the reactions of a post
func GetCmdQueryPostReactions() *cobra.Command {
cmd := &cobra.Command{
Use: "post-reactions [post-id]",
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 we can rename this to simply be reactions since the registered reactions is already registered-reactions. We don't need to specify these are posts reactions IMO

x/staging/posts/keeper/common_functions.go Outdated Show resolved Hide resolved
}
}

store.Delete(key)
return nil
}

// GetPostReactions returns the list of reactions that has been associated to the post having the given id
func (k Keeper) GetPostReactions(ctx sdk.Context, postID string) []types.PostReaction {
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 method can now be deleted since we are using the store prefix iterator to get the post reactions inside the gRPC method. Or maybe this is used somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used in operation_reaction.go to simply get post reactions in the post in 1 line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since that's a test, I think we can move it inside that test directly without exposing it publicly to other modules

Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@dadamu
Copy link
Contributor Author

dadamu commented Jun 28, 2021

Great job! 🚀 There are some minor things to tweak but otherwise looks very good.
I see that you also improved the registered reactions query, or am I wrong? Maybe it's worth adding a CHANGELOG entry for that one as well?

Yes, I improved registered reactions a bit by removing the unused struct and adding iterate function. I will add it as well into CHANGELOG.

@dadamu dadamu requested a review from RiccardoM June 28, 2021 06:58
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.

Everything looks great to me...I'll approve this once sims are fixed 💪

docs/developers/queries/staging/reactions.md Outdated Show resolved Hide resolved
docs/developers/queries/staging/reactions.md Outdated Show resolved Hide resolved
x/staging/posts/client/cli/query.go Outdated Show resolved Hide resolved
@RiccardoM RiccardoM merged commit b919371 into master Jun 30, 2021
@RiccardoM RiccardoM deleted the paul/add-post-reactions-query branch June 30, 2021 13:24
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 PostReactions paginated query method
3 participants