Skip to content

David/driver history csv route#56

Merged
ludavidca merged 16 commits intomainfrom
david/driver-history-csv-route
Nov 22, 2025
Merged

David/driver history csv route#56
ludavidca merged 16 commits intomainfrom
david/driver-history-csv-route

Conversation

@ludavidca
Copy link
Collaborator

@ludavidca ludavidca commented Nov 15, 2025

JIRA ticket link

Driver history CSV export

Implementation description

  • Finalized api requirements with PM
  • Completed Implementation of API Route to export CSV file with filtering
  • Added line to utils in csv to ensure that insertion order is preserved

Steps to test

  1. Seed the database
  2. Call api with params driver_id = all and current year

What should reviewers focus on?

  • If overall implementation makes sense

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@ludavidca ludavidca requested a review from ColinToft November 15, 2025 06:35
@ColinToft ColinToft requested a review from Copilot November 17, 2025 03:20
Copy link
Contributor

Copilot AI left a 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 implements a CSV export feature for driver history data, allowing users to export driving distance records for all drivers across two consecutive years. The implementation includes filtering by year and preserves field insertion order in the CSV output.

Key Changes:

  • Added a new API endpoint /drivers/{driver_id}/history/{year}/export that generates and streams CSV files
  • Implemented DriverHistoryCSVGenerator service to handle CSV generation logic with custom sorting
  • Enhanced CSV utility to preserve field insertion order using dict.fromkeys()

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
backend/python/app/utilities/csv_utils.py Modified field name extraction to preserve insertion order instead of using unordered set
backend/python/app/services/implementations/driver_history_service.py Added get_driver_history_by_year() method to query driver histories by year
backend/python/app/services/implementations/driver_history_csv_service.py New service class implementing CSV generation logic with sorting and formatting
backend/python/app/routers/driver_history_routes.py Added new export endpoint with validation for "all" driver_id parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@ColinToft ColinToft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple comments!

@ludavidca ludavidca merged commit 26f0975 into main Nov 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants