Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description This PR adds a new `profile_counters` table that stores the counter for various things related to a profile, such as relationships, blocks, chain links and application links. This is done to allow the clients to get such data without having to perform `COUNT` queries that are notouriously costly from a performance perspective. In order to have this code working properly, the following table needs to be created: ```sql CREATE TABLE profile_counters ( row_id SERIAL NOT NULL PRIMARY KEY, profile_address TEXT NOT NULL, relationships_count BIGINT NOT NULL DEFAULT 0, blocks_count BIGINT NOT NULL DEFAULT 0, chain_links_count BIGINT NOT NULL DEFAULT 0, application_links_count BIGINT NOT NULL DEFAULT 0, CONSTRAINT unique_profile_counters UNIQUE (profile_address) ); ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved transaction handling in database operations for saving and deleting chain links, application links, relationships, and user blocks to enhance data integrity and consistency. - **New Features** - Added a new SQL function to check if a user is following a specified profile, improving user interaction capabilities. - Introduced a `profile_counters` table to optimize performance by precomputing counts related to profiles. - **Tests** - Expanded testing for profile, chain link, and relationship management functionalities to ensure robustness and reliability of changes. - **Chores** - Removed redundant function for following profile check, streamlining database schema. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information