-
Notifications
You must be signed in to change notification settings - Fork 46
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
PostReaction struct improvements #160
Conversation
fixed tests: TODO: - update docs - migration
fixed bugs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-reviewed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes looks overall good to me, however I would change just two small things.
x/posts/internal/keeper/querier.go
Outdated
} else { | ||
registeredReaction, _ := keeper.GetRegisteredReaction(ctx, reaction.Value, post.Subspace) | ||
reactionValue = registeredReaction.Value | ||
} | ||
reactionsResponses[index] = types.ReactionQueryResponse{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the new PostReaction
type is pretty much equal to the ReactionQueryResponse
type, I think that we can delete the latter and leave only the PostReaction
type to be used inside the PostQueryResponse
object.
Codecov Report
@@ Coverage Diff @@
## master #160 +/- ##
==========================================
+ Coverage 82.83% 83.13% +0.30%
==========================================
Files 57 58 +1
Lines 2423 2449 +26
==========================================
+ Hits 2007 2036 +29
+ Misses 357 356 -1
+ Partials 59 57 -2 |
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
…prov' into leonardo/post-reaction-struct-improv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some unwanted changes in the tests
expected := `ID: dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1 | ||
Reactions: [{"owner":"cosmos1s3nh6tafl4amaxkke9kdejhp09lk93g9ev39r4","shortcode":"https://example.com/like","value":":like:"} {"owner":"cosmos15lt0mflt6j9a9auj7yl3p20xec4xvljge0zhae","shortcode":"👍","value":":+1:"}] | ||
Children: [dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1, dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert these lines as they should not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything should be fine now, there was a problem inside the PostReaction
type where its fields are alfabetically ordered (probably due to a refactor that I've done).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still something fishy about the tests. You are creating the reactions as follows:
[]models.PostReaction{
models.NewPostReaction(":like:", "https://example.com/like", liker),
models.NewPostReaction(":+1:", "👍", otherLiker),
},
But then you are testing if the result is
[
{
"owner": "cosmos1s3nh6tafl4amaxkke9kdejhp09lk93g9ev39r4",
"shortcode": "https://example.com/like",
"value": ":like:"
}
{
"owner": "cosmos15lt0mflt6j9a9auj7yl3p20xec4xvljge0zhae",
"shortcode": "👍",
"value": ":+1:"
}
]
As you can see in the result the value
and shortcode
values are inverted. There is either an error in the test or an error somewhere else. Please make the test expected result correct (invert those values) and fix the bug accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's because I've not commit the changes yet
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a wrong test expected result
expected := `ID: dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1 | ||
Reactions: [{"owner":"cosmos1s3nh6tafl4amaxkke9kdejhp09lk93g9ev39r4","shortcode":"https://example.com/like","value":":like:"} {"owner":"cosmos15lt0mflt6j9a9auj7yl3p20xec4xvljge0zhae","shortcode":"👍","value":":+1:"}] | ||
Children: [dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1, dd065b70feb810a8c6f535cf670fe6e3534085221fa964ed2660ebca93f910d1]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still something fishy about the tests. You are creating the reactions as follows:
[]models.PostReaction{
models.NewPostReaction(":like:", "https://example.com/like", liker),
models.NewPostReaction(":+1:", "👍", otherLiker),
},
But then you are testing if the result is
[
{
"owner": "cosmos1s3nh6tafl4amaxkke9kdejhp09lk93g9ev39r4",
"shortcode": "https://example.com/like",
"value": ":like:"
}
{
"owner": "cosmos15lt0mflt6j9a9auj7yl3p20xec4xvljge0zhae",
"shortcode": "👍",
"value": ":+1:"
}
]
As you can see in the result the value
and shortcode
values are inverted. There is either an error in the test or an error somewhere else. Please make the test expected result correct (invert those values) and fix the bug accordingly.
fixed a bug inside IndexOfByUserAndValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR improves the
PostReaction
type structure to allow a better integration with middle layer applications.Closes #157.
Checklist
CHANGELOG.md
file.Files changed
in the Github PR explorer.