Repository navigation
#9 Weekly earnings summary for drivers - #39
Open
anishsingla2910 wants to merge 1 commit into
Open
anishsingla2910 wants to merge 1 commit into
anishsingla2910 wants to merge 1 commit into
Conversation
Drivers saw only today's cash. Add GET /drivers/me/earnings?days=7 (1-31), drivers only: completed rides summed per calendar day in India time, with a row for every day so the app can draw each bar, plus the total and trip count. Days are bucketed in IST, not UTC, so a ride finished at 00:30 in Mumbai belongs to that day even though it is still the previous evening in UTC. Driver app: under today's figure, the week total and trip count and a bar per day (Mon..Sun, "Today" last), with accessibility labels. Weekday names are derived from the calendar date, not from the phone's timezone. Tests: IST day boundaries (23:30 and 00:30), the window edge (days=7 vs 8), cancelled rides not counted, empty days as 0, 422 outside 1-31, 403 for riders; Jest for the API call and the label/bar helpers; the e2e ride now also checks the week block on the Earnings screen.
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 #9
What changed
Backend
GET /drivers/me/earnings?days=7(days1–31, drivers only): total earnings, trip count and a per-day list for completed rides, with a row for every day (0 when idle) so the app can draw each bar.routing.IST): a ride finished at 00:30 in Mumbai belongs to that day, although it is still the previous evening in UTC. Grouping happens in Python, so SQLite and PostgreSQL behave the same.backend/app/services/earnings.py; response modelsEarningsOut/EarningsDayOutinschemas.py; endpoint documented indocs/BACKEND.md.Driver app
api.earnings(days)and theEarningstypes.src/lib/earnings.ts).Tests
backend/tests/test_api.py::test_driver_earnings_count_days_in_india_time: 23:30 IST stays on its day; 00:30 IST (19:00 UTC the previous evening) counts for the new day; a ride 7 days ago is outsidedays=7and insidedays=8; cancelled rides are not counted; empty days are 0;days=0/32→ 422; riders → 403.earnings.test.ts(weekday label, bar scaling) and theapi.earningsURL.e2e/run_e2e.py) now also checks "Last 7 days" and "1 trip" on the driver's Earnings screen.python test_all.pypasses: 124 Python tests, 34 Jest tests, typecheck, lint, and the 11-step browser ride.Screenshot
Driver app after two rides (real phone, backend in straight-line mode):