spayd-applied

Changes Summary - Back Date Days (History Limit) Feature

Issue Reported

Root Causes

  1. Incorrect API URL: Using www.fioapi.cz instead of fioapi.fio.cz
  2. Flawed URL construction logic: Complex parsing logic led to wrong domain
  3. Missing dependency: requests library not in pyproject.toml
  4. Poor error handling: Generic error messages not helpful to users
  5. No input validation: Frontend allowed invalid values
  6. Security issue: Token exposed in error logs and messages

Changes Made

Backend (Python API) - fio_fetch_py/

1. fiofetch/api.py

2. pyproject.toml

3. Documentation

Frontend (React/Preact UI) - fio_fetch_webui/

1. src/components/FetchControl.jsx

Testing Checklist

After deploying these changes:

API Changes

New/Modified Endpoints

POST /api/v1/set-last-date

Request:

{
  "days_back": 3 // Optional, defaults to config value
}

Success Response (200):

{
  "message": "Successfully set last date to 2025-11-25 (3 days back)",
  "target_date": "2025-11-25",
  "days_back": 3
}

Error Responses:

GET /api/v1/config

Response now includes:

{
  ...
  "back_date_days": 3
}

POST /api/v1/config

Request can now include:

{
  "back_date_days": 7 // Optional
}

Configuration Options

New configuration option:

Migration Notes

No breaking changes. All existing functionality remains intact.

New functionality is additive:

Files Modified

Backend

Frontend

Deployment Steps

  1. Update backend dependencies:

    cd fio_fetch_py
    uv sync
    
  2. Restart backend server:

    # Stop existing server
    # Start with updated code
    fiofetch
    
  3. No frontend rebuild needed (unless you want to)

    • The changes are in JSX files
    • If using dev server, changes will hot reload
    • If using production build, rebuild and deploy
  4. Verify:

    # Check API is working
    curl http://localhost:3000/api/v1/config
    
    # Should show: "back_date_days": 3
    

Known Limitations

Future Enhancements (Optional)