-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Implement historical pricing for message cost recalculation #813
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
base: main
Are you sure you want to change the base?
feat: Implement historical pricing for message cost recalculation #813
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.
I think that we shouldn't have to modify a migration already executed on the rest of the CCNs to prevent unconsistencies on the database.
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.
We are still using a constant (DEFAULT_PRICE_AGGREGATE
) with the same hardcoded default pricing than before. The only change is a type conversion from Dict[str, dict]
to Dict[ProductPriceType, ProductPricing]
which is the type that the migration uses
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.
Anyway, I think that we don't have to touch an already executed migration, just to be sure that doesn't crash and for keeping the same migration history on all the CCNs.
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.
Everything looks good except the migration change, that I prefer to leave as is.
Summary
Implements historical pricing support for message cost recalculation, ensuring costs are calculated using the pricing models that were active when messages were originally created.
Key Changes
🔧 New Pricing Timeline System
⚡ Enhanced Cost Recalculation
🔄 Migration Refactoring
🧪 Comprehensive Testing
API Endpoints
Auth methods
The new endpoints have a basic token auth system with signed tokens that will expire after 5 minutes
./deployment/scripts/auth_token.py --create-token
X-Auth-Token
header with the base64 token generated by the scriptBenefits
✅ Historical Accuracy: Costs calculated using pricing active when messages were created✅ Performance: Efficient timeline processing without repeated DB queries✅ Maintainability:
Reusable pricing utilities reduce code duplication✅ Robustness: Comprehensive error handling and extensive test coverage