@vlodkow.near [Posted on DevHub](/devgovgigs.near/widget/Post?id=3099) ## Solution: Implement a users voting summary for voting-v1 smart-contracts **Objective** Enhance the existing smart-contract to include a new view method that returns detailed voting participation information of all users. This includes their voting choices (Approve, Reject, Abstain) across all proposals and the number of proposals they have created. **Existing Structure Summary** The current smart-contract includes structures for recording individual votes and proposals. However, it lacks a consolidated view of voting participation by each user. **Implementation Steps** *1. Define New Structure CollectedResults* This structure will aggregate voting results for each user. Fields for structure: * approves: u16 - Total number of approvals. * rejects: u16 - Total number of rejections. * abstains: u16 - Total number of abstentions. * created: u16 - Number of proposals created by the user. *2. Add New Data Storage usercollectedresults* Type: `UnorderedMap<AccountId, CollectedResults>`. Purpose: Store the aggregated voting results for each user with ability to return the data in a single view method. *3. Develop a Method to Populate usercollectedresults from Existing Data* Iterate over existing proposals. For each proposal, update CollectedResults for each voter and the proposer. Ensure data consistency and integrity during the aggregation process. *4. Modify Voting Mechanism to Update usercollectedresults on Each Vote* When a vote is cast, update the corresponding user's CollectedResults in user_collected_results. When a new proposal is created, increment the proposals_created count for the proposer in user_collected_results. *5. Create a View Method getvotingparticipation* Returns: A list of all users along with their aggregated voting results. Functionality: Provides a complete list of users along with their voting records and proposal counts. **Considerations** Performance: Ensure that the updates to user_collected_results are efficient, especially for large number of proposals and users. Data Migration: Consider the need for data migration for existing proposals to populate user_collected_results. Security: Review and test for potential security vulnerabilities, especially in the data aggregation logic. **Documentation updates** Update the contract documentation to reflect the new features and changes. **Smart-Contracts to Update** The following deployed smart-contracts will be updated with the new features: * congress-hom-v1.ndc-gwg.near * congress-tc-v1.ndc-gwg.near * congress-coa-v1.ndc-gwg.near The current project repository is available at [NEAR NDC Voting V1](https://github.com/near-ndc/voting-v1).