-
Notifications
You must be signed in to change notification settings - Fork 378
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
feat(blog): store posts in slices & include chronological sorting #1367
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1367 +/- ##
=======================================
Coverage 55.91% 55.91%
=======================================
Files 421 421
Lines 65444 65444
=======================================
Hits 36595 36595
Misses 25991 25991
Partials 2858 2858 ☔ View full report in Codecov by Sentry. |
@thehowl will do a more detailed refactor once I'm back from Devconnect - or, @waymobetta, if you've the time to jump on this you can. |
Hey @thehowl, I refactored with the suggestions that you guys made. I did some small reorgs of the package as well. Since the |
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.
Mostly LGTM
sounds good to me. |
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.
just reviewed again, this LGTM, but I would still remove types.go and move its types back into the respective files
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.
"gno.land/p/demo/seqid" | ||
"std" | ||
"time" |
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.
Should we configure our linter to flag import style issues?
cc @gnolang/tech-staff
Comment string | ||
} | ||
|
||
type postSlice []*Post |
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.
Shouldn't we use seqid
with an avl.Tree
instead of a slice? I believe it allows for an always growing key string, which would help keep the avl.Tree
ordered. cc @thehowl
for _, post := range p { | ||
if post.Slug == slug { |
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 goal of an AVL tree is to optimize the lazy loading of necessary data and skip unnecessary posts. Unlike this implementation, an AVL tree is scalable and will efficiently handle larger data sets.
Closing this PR to start on a clean slate because of the feedback I've received. Will implement this change with seqID / AVLs. New PR: #1541 |
Description
This PR implements a modification in the storage mechanism for blog posts within the
p/demo/blog
package. Previously, an AVL tree was used for storing posts, leading to an inconsistent order during retrieval.Now, the PR updates the
Blog
struct to incorporate apostSlice
struct, replacing the AVL tree. This change ensures that blog posts are maintained in the order how they were added, providing a consistent and predictable order.Also, as per @thehowl's suggestion, the
postSlice
struct implements the sort.Sort interface, allowing for sorting by date of creation down the line when needed.cc @thehowl @moul
Fixes gnolang/blog#20, fixes #1285.
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description