Skip to content

Add export fleet CSV endpoint to URLs#210

Open
shay-coding wants to merge 1 commit intomainfrom
shay-coding-patch-1
Open

Add export fleet CSV endpoint to URLs#210
shay-coding wants to merge 1 commit intomainfrom
shay-coding-patch-1

Conversation

@shay-coding
Copy link
Collaborator

@shay-coding shay-coding commented Jan 7, 2026

Summary by CodeRabbit

New Features

  • Added CSV export functionality for fleet vehicles data, allowing operators to download their fleet information in spreadsheet-compatible format.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Walkthrough

A new URL route was added to the fleet application enabling CSV export of vehicle fleet data. The route maps to an export_fleet_csv view at the endpoint operator/<str:operator_slug>/vehicles/export/, registered alongside existing fleet management routes.

Changes

Cohort / File(s) Summary
Fleet URL routing
fleet/urls.py
Added new URL pattern for CSV fleet export at operator-specific vehicles endpoint; view endpoint export_fleet_csv registered with route parameter for operator slug

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, skip, and a CSV bound,
Fleet data flows, export-found!
One route added, clean and tight,
Operators export with delight! 🚗📊

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new CSV export endpoint for fleet data to the URL routing configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @fleet/urls.py:
- Line 100: The URL pattern uses an extra "operator/" prefix and should match
the existing vehicle routes; update the route definition for export_fleet_csv to
use "<str:operator_slug>/vehicles/export/" (matching the other patterns like the
ones on lines 88-99) instead of "operator/<str:operator_slug>/vehicles/export/"
so the exported CSV URL is "/<operator_slug>/vehicles/export/"; keep the view
name export_fleet_csv and name='export_fleet_csv' unchanged.
🧹 Nitpick comments (1)
fleet/urls.py (1)

2-2: Consider replacing wildcard imports with explicit imports.

While wildcard imports (from fleet.views import *) are commonly used in Django URL configurations, explicit imports improve code clarity and make it easier to identify missing imports at development time rather than runtime.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a584c4 and 57780f1.

📒 Files selected for processing (1)
  • fleet/urls.py
🧰 Additional context used
🪛 Ruff (0.14.10)
fleet/urls.py

100-100: export_fleet_csv may be undefined, or defined from star imports

(F405)

path('<str:operator_slug>/vehicles/<int:vehicle_id>/list_for_sale/', vehicle_sell, name='vehicle_sell'),
path('<str:operator_slug>/vehicle/edit/<int:vehicle_id>/', vehicle_edit, name='vehicle_edit'),
path('<str:operator_slug>/vehicles/dedupe', deduplicate_operator_fleet, name='deduplicate_fleet'),
path('operator/<str:operator_slug>/vehicles/export/', export_fleet_csv, name='export_fleet_csv'),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix the URL pattern to match existing vehicle routes.

The URL pattern has an inconsistent operator/ prefix that doesn't match other vehicle-related routes in this file. All existing vehicle URLs follow the pattern <str:operator_slug>/vehicles/... (lines 88-99), but this new route uses operator/<str:operator_slug>/vehicles/....

This inconsistency will result in a URL like /operator/my-operator/vehicles/export/ instead of the expected /my-operator/vehicles/export/, breaking the established URL structure.

🔧 Proposed fix to align with existing URL pattern
-    path('operator/<str:operator_slug>/vehicles/export/', export_fleet_csv, name='export_fleet_csv'),
+    path('<str:operator_slug>/vehicles/export/', export_fleet_csv, name='export_fleet_csv'),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path('operator/<str:operator_slug>/vehicles/export/', export_fleet_csv, name='export_fleet_csv'),
path('<str:operator_slug>/vehicles/export/', export_fleet_csv, name='export_fleet_csv'),
🧰 Tools
🪛 Ruff (0.14.10)

100-100: export_fleet_csv may be undefined, or defined from star imports

(F405)

🤖 Prompt for AI Agents
In @fleet/urls.py at line 100, The URL pattern uses an extra "operator/" prefix
and should match the existing vehicle routes; update the route definition for
export_fleet_csv to use "<str:operator_slug>/vehicles/export/" (matching the
other patterns like the ones on lines 88-99) instead of
"operator/<str:operator_slug>/vehicles/export/" so the exported CSV URL is
"/<operator_slug>/vehicles/export/"; keep the view name export_fleet_csv and
name='export_fleet_csv' unchanged.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if export_fleet_csv view is defined in fleet/views.py or its imported modules

# Search for the function definition in Python files
rg -n --type=py 'def export_fleet_csv' 

# Also search for all references to understand where it's used
echo "=== All references to export_fleet_csv ==="
rg -n --type=py 'export_fleet_csv'

Repository: NextStopLabs/MyBusTimes

Length of output: 229


🏁 Script executed:

#!/bin/bash
# Check imports at the top of fleet/urls.py
echo "=== Imports in fleet/urls.py ==="
head -n 30 fleet/urls.py | cat -n

# Check what views exist in fleet/views.py
echo -e "\n=== Functions/views in fleet/views.py ==="
rg -n --type=py '^def ' fleet/views.py | head -n 20

Repository: NextStopLabs/MyBusTimes

Length of output: 3437


Implement the missing export_fleet_csv view in fleet/views.py.

The view function is referenced in fleet/urls.py at line 100 but does not exist in fleet/views.py. This will cause a runtime error when the endpoint is accessed. Add the view function to fleet/views.py before merging.

🧰 Tools
🪛 Ruff (0.14.10)

100-100: export_fleet_csv may be undefined, or defined from star imports

(F405)

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.

1 participant