-
Notifications
You must be signed in to change notification settings - Fork 5
feat: added getAdvancedProjectStats function #52
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
Conversation
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.
Pull Request Overview
This PR adds advanced project statistics calculation for Angor projects, introducing a new getAdvancedProjectStats function and extending the statistics interface to include a new property for tracking investor spending without penalties (disabled until Angor v2).
Key changes:
- Implemented
getAdvancedProjectStatsfunction inangor-stats.tsto analyze blockchain transactions and categorize spending patterns - Added
amountSpentSoFarByInvestorNoPenaltyproperty toAdvancedProjectStatsinterface with placeholder logic for future Angor v2 support - Refactored the stats collection logic in
angor.routes.tsto use the new async function instead of the previous synchronous approach
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| frontend/sync-assets.js | Added input validation to prevent malformed downloads and fixed typo in URL replacement |
| backend/src/api/angor/angor.routes.ts | Refactored to use new getAdvancedProjectStats function and added new stats property |
| backend/src/api/angor/angor-stats.ts | Added new async getAdvancedProjectStats function with blockchain transaction analysis logic |
| backend/src/api/angor/angor-stats.test.ts | Added comprehensive test coverage for the new stats function with mock transaction data |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 0 | ||
| ); | ||
| } else { | ||
| // The following kinf of transaction are planned in Angor projects v2. |
Copilot
AI
Oct 20, 2025
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.
Corrected spelling of 'kinf' to 'kind'.
| // The following kinf of transaction are planned in Angor projects v2. | |
| // The following kind of transaction are planned in Angor projects v2. |
| if (filteredInvestments.length > 0) { | ||
| const spentVouts: AngorVout[][] = await Promise.all( | ||
| await Promise.all( | ||
| investments.map(async (investment) => { |
Copilot
AI
Oct 20, 2025
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 result of Promise.all is not being used. Since getAdvancedProjectStats is called for side effects (accumulating stats), this creates a fire-and-forget pattern that could lead to race conditions where stats might not be fully accumulated before being returned. The await should be kept, but the mapping function should properly wait for each investment's stats to be accumulated.
| investments.map(async (investment) => { | |
| filteredInvestments.map(async (investment) => { |
| amountSpentSoFarByInvestorNoPenalty: 0, | ||
| }; | ||
|
|
||
| // scriptpubkey_type v1_p2tr indicates that it a stage vout |
Copilot
AI
Oct 20, 2025
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.
Missing word in comment. Should be 'that it is a stage vout'.
| // scriptpubkey_type v1_p2tr indicates that it a stage vout | |
| // scriptpubkey_type v1_p2tr indicates that it is a stage vout |
Intent
query/Angor/projects/:projectID/statsAPI endpoint.amountSpentSoFarByInvestorNoPenaltyproperty to theAdvancedProjectStatsinterface (the logic collecting this stats is disabled until Angor v2).Implementation
getAdvancedProjectStatsfunction tobackend/src/api/angor/angor-stats.tsfile.backend/src/api/angor/angor.routes.tsto usegetAdvancedProjectStatsfunction instead ofcomputeAdvancedStatsfunction.