Southclaws / storyden

With a fresh new take on traditional bulletin board forum software, Storyden is a modern, secure and extensible platform for building communities.
https://www.storyden.org/
Mozilla Public License 2.0
93 stars 11 forks source link

Rework collections #272

Closed Southclaws closed 2 weeks ago

Southclaws commented 3 weeks ago

This pull request introduces several significant changes to the api/openapi.yaml file and the collection package in the codebase. The changes include adding new query parameters, modifying schema components, and refactoring the code for better modularity and functionality.

Changes to api/openapi.yaml:

Changes to collection package:

These changes enhance the flexibility and functionality of the collection management system by adding new query capabilities and improving code organization.

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
storyden ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 1, 2024 11:36am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **storyden-homepage** | ⬜️ Ignored ([Inspect](https://vercel.com/southclaws-projects/storyden-homepage/FairLHNqanHaJoe7qpq2QCzhKFxQ)) | [Visit Preview](https://storyden-homepage-git-rework-collections-southclaws-projects.vercel.app) | | Nov 1, 2024 11:36am |
coderabbitai[bot] commented 3 weeks ago

[!WARNING]

Rate limit exceeded

@Southclaws has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
📥 Commits Reviewing files that changed from the base of the PR and between 62adfd3989878e9b0421b3238111acab0433a3d0 and 6738cac33085a5b69ae89b0dd0621c474dd48900.
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes in this pull request involve significant restructuring and enhancements across various components of the collection management system. Key modifications include the introduction of new types and fields, such as optional descriptions and item counts, as well as the implementation of a more modular approach with dedicated manager and querier structures. Functions related to collection mapping and item management have been refactored, and several new methods have been added to facilitate better handling of collection items and statuses. Additionally, there are updates to the API schema to reflect these changes. ## Changes | File Path | Change Summary | |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | app/resources/collection/collection.go | - Updated `Description` field to `opt.Optional[string]` in `Collection` struct.
- Added `ItemCount` and `HasQueriedItem` fields.
- Refactored `MapCollection` to `Map`. | | app/resources/collection/collection_item/item.go | - Introduced `Repository` struct for data access.
- Updated `MembershipType` references.
- Modified `UpdateItems` and `ProbeItem` methods to use the new `Repository`. | | app/resources/collection/collection_item_status/status.go | - Added `Status` and `CollectionStatusResult` structs for item status management.
- Introduced methods for mapping and retrieving status information. | | app/resources/collection/collection_querier/querier.go | - Added `Querier` struct for database interaction.
- Implemented methods for listing and retrieving collections with optional filters. | | app/resources/collection/collection_writer/writer.go | - Introduced `Writer` struct for managing collections.
- Added methods for creating, updating, and deleting collections with error handling. | | app/resources/collection/db.go | - Deleted file containing previous database management logic. | | app/resources/collection/repo.go | - Deleted file containing the `Repository` interface and related functions. | | app/resources/event/event.go | - Updated `Map` function to change `thread.FromModel` call signature. | | app/resources/library/mapping.go | - Added `Collections` field to `Node` return type. | | app/resources/library/node.go | - Added `Collections` field to `Node` struct. | | app/resources/post/post.go | - Added `Collections` field to `Post` struct. | | app/resources/post/reply/reply.go | - Added `Collections` field to `Reply` struct. | | app/resources/post/thread/db.go | - Updated `Create` and `Update` methods to accommodate new parameter in `FromModel`. | | app/resources/post/thread/thread.go | - Removed `Collections` field from `Thread` struct and updated `FromModel` function to use `CollectionStatusMap`. | | app/resources/resources.go | - Updated imports to use specific collection-related packages. | | app/services/collection/collection_auth/auth.go | - Introduced permission-checking functions for collections and collection items. | | app/services/collection/collection_item_manager/manager.go | - Added `Manager` struct for managing collection items with methods for adding/removing posts and nodes. | | app/services/collection/collection_manager/manager.go | - Introduced `Manager` struct for managing collections with methods for creating, updating, and deleting collections. | | app/services/collection/collection_read/reader.go | - Renamed `CollectionQuerier` to `Hydrator` and updated methods to use the new struct. | | app/services/collection/provider.go | - Added `Build` function for dependency injection of collection-related services. | | app/services/collection/service.go | - Deleted file containing previous service implementation for collections. | | app/transports/http/bindings/collections.go | - Updated `Collections` struct to use new manager and querier types.
- Modified methods to utilize new interfaces for collection operations. | | app/transports/http/bindings/utils.go | - Updated serialization functions to handle new `Collections` field logic. | | internal/ent/collection.go | - Changed `Description` field from `string` to `*string` for nullable handling. | | internal/ent/collection/where.go | - Added `DescriptionIsNil` and `DescriptionNotNil` functions for null checks. | | internal/ent/collection_create.go | - Introduced `SetNillableDescription` method for conditional setting of the description. | | internal/ent/collection_update.go | - Added `ClearDescription` method to allow clearing of the description field during updates. | | internal/ent/migrate/schema.go | - Updated `description` field in `CollectionsColumns` to be nullable. | | internal/ent/schema/collection.go | - Modified `Fields` method to make `description` optional and nillable. | | tests/collection/crud_test.go | - Updated tests to handle `Description` as a pointer. | | tests/collection/items_test.go | - Added new test cases for collection functionalities. | | tests/collection/submissions_test.go | - Simplified collection creation tests by removing the `Description` parameter. | | web/src/api/openapi-schema/collection.ts | - Extended `Collection` type to include `CollectionAdditionalProps`. | | web/src/api/openapi-schema/collectionAdditionalProps.ts | - Added `CollectionAdditionalProps` interface for additional collection properties. | | web/src/api/openapi-schema/collectionCommonProps.ts | - Changed `description` property to optional in `CollectionCommonProps`. | | web/src/api/openapi-schema/collectionCount.ts | - Introduced `CollectionCount` type definition. | | web/src/api/openapi-schema/collectionHasItemQueryParamParameter.ts | - Added `CollectionHasItemQueryParamParameter` type for query parameters. | | web/src/api/openapi-schema/collectionInitialProps.ts | - Changed `description` property to optional in `CollectionInitialProps`. | | web/src/api/openapi-schema/collectionListParams.ts | - Added optional `has_item` property to `CollectionListParams`. | | web/src/api/openapi-schema/collectionStatus.ts | - Introduced `CollectionStatus` interface with properties for collection status. | | web/src/api/openapi-schema/hasCollected.ts | - Added `HasCollected` type definition. | | web/src/api/openapi-schema/index.ts | - Added new exports for additional properties and types. | | web/src/api/openapi-schema/linkProps.ts | - Removed `collections` property from `LinkProps` interface. | | web/src/api/openapi-schema/postReferenceProps.ts | - Changed `collections` property type from `CollectionList` to `CollectionStatus`. | | web/src/components/content/CollectionCreate/CollectionCreateTrigger.tsx | - Adjusted `onClick` event handler positioning in `Button` component. | | web/src/components/content/CollectionMenu/CollectionMenu.tsx | - Added state management for multi-selection and refactored rendering logic. | | web/src/components/content/CollectionMenu/useCollectionMenu.ts | - Simplified logic for fetching collections and handling selections. | | web/src/lib/collection/mutation.ts | - Introduced hooks for managing collection items with methods for adding/removing posts and nodes. | ## Poem > In the garden of collections, we hop and play, > With new fields and functions, brightening the day. > Optional descriptions, and counts that do cheer, > Our code now more nimble, let’s give a loud cheer! 🐇✨ > With every new feature, our joy does expand, > In the world of our collections, together we stand!

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.