Skip to content

feat: Implement region pack download with progress tracking#26

Merged
mverteuil merged 4 commits intomainfrom
fix/region-pack-button-handler
Feb 22, 2026
Merged

feat: Implement region pack download with progress tracking#26
mverteuil merged 4 commits intomainfrom
fix/region-pack-button-handler

Conversation

@mverteuil
Copy link
Owner

Summary

  • Add JavaScript handler for region pack download button
  • Implement background download processing via update daemon using Redis queue
  • Add download progress polling with real-time UI updates
  • Fix region pack detection to recognize new na-east-### naming pattern

Changes

New Files

  • src/birdnetpi/releases/region_pack_service.py - Reusable download logic for CLI and daemon

Modified Files

  • src/birdnetpi/daemons/update_daemon.py - Process region pack download requests from Redis
  • src/birdnetpi/releases/region_pack_status.py - Fix pack detection regex for new naming format
  • src/birdnetpi/web/models/update.py - Add RegionPackDownloadStatusResponse Pydantic model
  • src/birdnetpi/web/routers/update_api_routes.py - Add /region-pack/download-status endpoint
  • src/birdnetpi/web/routers/i18n_api_routes.py - Add translation keys for download status
  • src/birdnetpi/web/static/js/update.js - Add progress polling and UI updates

How It Works

  1. User clicks "Download region pack" button
  2. FastAPI queues download request in Redis
  3. Update daemon picks up request and downloads pack in background
  4. Progress is stored in Redis (region_pack:download_status)
  5. JavaScript polls for progress and updates button text (e.g., "Downloading 45% (10.5/24.3 MB)")
  6. On completion, page reloads and banner disappears

Test Plan

  • Click download button on update page
  • Verify button shows download progress percentage
  • Verify region pack banner disappears after installation
  • Verify pack appears in database directory

The "Download Region Pack for My Location" button was missing its click
handler. Added regionPackManager object that:
- Listens for button clicks
- Calls the POST /api/update/region-pack/download endpoint
- Shows download status via button text and notifications
- Handles success/error states appropriately

Note: The API endpoint queues the download request but the background
worker to process the queue is not yet implemented.
- Create RegionPackService for reusable region pack download logic
- Add download_from_url method for daemon use without full RegionPackInfo
- Integrate region pack download processing into update daemon monitor loops
- Store download progress in Redis for UI status updates
- Queue download requests via Redis for inter-process communication
- Add RegionPackDownloadStatusResponse Pydantic model for API docs
- Add /region-pack/download-status endpoint to poll download progress
- Update JavaScript to poll for progress and show percentage on button
- Add i18n translation keys for download status messages
- Fix region pack detection to recognize new na-east-### naming pattern
- Banner now correctly hides when region pack is installed
- Fix species checklist 500 error when there are no detections by handling
  NULL values from SQL SUM (which returns NULL for empty result sets)
- Add comprehensive test suite for RegionPackService to meet 77% coverage
  threshold (region_pack_service.py now has 96% coverage)
@mverteuil mverteuil merged commit 294566d into main Feb 22, 2026
5 of 6 checks passed
@mverteuil mverteuil deleted the fix/region-pack-button-handler branch February 22, 2026 04:46
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