feat: Add property price history tracking and analytics endpoints#656
Open
Risktaker001 wants to merge 2 commits into
Open
feat: Add property price history tracking and analytics endpoints#656Risktaker001 wants to merge 2 commits into
Risktaker001 wants to merge 2 commits into
Conversation
…story entity with complete audit trail - Add price history recording with percentage calculations - Create API endpoints for history retrieval, charts, and exports - Implement permission-based access control - Add caching strategy for performance optimization - Support CSV and JSON export formats - Enable bulk export for multiple properties - Add time-based data aggregation (daily, weekly, monthly, yearly) - Implement comprehensive error handling and validation - Integrate with PropertiesModule and AuthModule - Closes MettaChain#333
|
@Risktaker001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Risktaker001 please kindly review yoyr code and stick to the scope of work related to the task assigned to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #333
DescriptionThis PR introduces comprehensive tracking for property price modifications within the NestJS backend ecosystem. Whenever a property's valuation shifts, the system now archives the alteration to maintain an auditable timeline. Additionally, it implements a public retrieval endpoint equipped with real-time financial math (such as delta variations) and formatted payloads optimized for frontend charting engines.ChangesDatabase & Schema UpdatesEntity Creation: Developed a new PropertyPriceHistory entity/schema capturing:id: Unique tracking record identifier.propertyId: Relation referencing the core Property record.oldPrice & newPrice: Valuation baselines prior to and succeeding the update.changePercentage: Calculated delta stored directly for indexed performance.changedAt: Chronological timestamp of the event.Property Lifecycle Interceptor: Hooked into the property updating routine to automatically write historical logs when price data keys deviate from the current database state.API Endpoint ArchitectureImplemented GET /properties/:id/price-history exposed through the controller layer.Refactored payload structures to serve structured data matrices required by downstream canvas charts (e.g., matching the ZandBox/Chart.js layout used on the frontend).Acceptance Criteria Verification[x] Record changes: Price mutations seamlessly yield precise event logs inside the relational history collections.[x] History endpoint: /properties/:id/price-history accurately surfaces complete asset change trajectories.[x] Change percentage: Calculated using the delta formula:$$\text{Change %} = \left( \frac{\text{New Price} - \text{Old Price}}{\text{Old Price}} \right) \times 100$$[x] Chart data: Returns chronologically mapped timestamp intervals paired alongside price values for chart rendering.Testing ChecklistIntegration & Service Coverage[ ] Test modifying a property's metadata without shifting price variables (Should not create a history row).[ ] Test updating a property's price value (Should capture exact bounds and accurate mathematical percentages).[ ] Test querying history for a non-existent property identifier (Should gracefully emit 404 Not Found).[ ] Verify chart payloads map perfectly array-to-array across ascending date boundaries.