Back cdr : Endpoint to get total of validated payments - #1028
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1028 +/- ##
===========================================
- Coverage 85.06% 51.31% -33.75%
===========================================
Files 220 220
Lines 16248 16288 +40
===========================================
- Hits 13821 8359 -5462
- Misses 2427 7929 +5502 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| select( | ||
| func.sum(models_cdr.Payment.total).label("total"), | ||
| ).where(models_cdr.Payment.year == cdr_year), | ||
| ) |
There was a problem hiding this comment.
Shouldn't we select all values then sum them in python instead? (asking because I genuinely don't know)
There was a problem hiding this comment.
From memory summing with SQL is always faster then taking the data and doing operation independently
| ] | ||
|
|
||
|
|
||
| async def get_total_payment_types( |
There was a problem hiding this comment.
get_payment_total_by_type maybe ? This crud kind of bothers me, nothing is wrong but I feel like we aren't doing anything like it anywhere else and there may be a reason (what I mean is for example that you are using a schema which wasn't meant for this kind of data for example... maybe what would be more usual would be to have and endpoint to get a total for a specific type and let the front ask for each one, or let the front do the entire computing, idk and I need a second opinion on this)
There was a problem hiding this comment.
Will it not pose a problem, if supposedly need to add a new form of payment, if we have to call for each type of payment ? You can argue that we have to hard code each new form of payment but it just add a new layer of complexity for this recurrent problem.
There was a problem hiding this comment.
I mean, you'd just need a for loop, it would without hard coding anything either way ¯\_(ツ)_/¯ I just find it kinda weird myself, but if I'm the only one, it's fine
There was a problem hiding this comment.
If I understand what you are suggesting : use a crud to get all the sellers/types, make a loop out of it where you get the total for each seller/type in the level of the endpoint. And after that, which schema do you send it to the front?
Description
Summary
Adding the endpoint for Enceladus to have the total payment done in the CDR and have the total of purchase that have been validated by the sellers.
...
Issues/PR dependencies
A futur PR in Enceladus will come to make use of this endepoint
Issues to be resolved
Required PRs
Changes Made
Additional Notes
Classification
Type of Change
Impact & Scope
Testing
Documentation
"Docstrings#Inline comments