Closed robbyphillips closed 5 years ago
The biggest change in this branch is upgrading the GET /api/posts
route to be able to handle several filtering and sort control query parameters:
categoryName
GET /api/categories/categoryName/posts
routeIn order to prevent duplication of work (and code), I suggest that we factor out a PostListContainer
component that can be used in the 3 places that we currently display lists of posts.
All of these use cases are very similar, and with a few small tweaks, we can have a reusable post-list component that has a well-featured sorting toolbar
Post model and API stabilized for now. In the future we should look at removing the 'voters' and 'purchasers' arrays on the model, and instead just update a count as needed when we hit other api routes.
Initial experimentation in this branch was aimed at removing all arrays of objectId from the post model, but using aggregation pipelines to count the number of transactions (calculate votes) proved to be far too expensive. If we are sorting thousands of posts with hundreds of vote transactions each, we need a faster way to built that sort query.
As such, I think we will need to maintain counters on the post model by incrementing a count field whenever we log a transaction. Currently, we do this for comments, but not for purchase or vote transactions.
The post seed script now makes a lot of posts that are, in general, much longer than we had before. There is also a chance that the random post will use codeblock and blockquote styles. This is configurable, and it might be worth adding random bits of other formatting like inline styles at a later time.
Additionally, we now have pagination on the main post list views with a 'More' button to get more posts. Unfortunately, this introduces 2 known problems:
Also, pagination still needs to be implemented on the profile page.