Feature: Tilføjet /api/v1/settings/sync-from-env endpoint til at synkronisere .env værdier ind i settings database
This commit is contained in:
parent
180ae7f650
commit
35447cbd4f
56
RELEASE_NOTES_v1.3.5.md
Normal file
56
RELEASE_NOTES_v1.3.5.md
Normal file
@ -0,0 +1,56 @@
|
||||
# Release Notes - v1.3.5
|
||||
|
||||
**Release Date:** 22. december 2025
|
||||
|
||||
## 🐛 Bug Fixes
|
||||
|
||||
### E-conomic Sync
|
||||
- **Fixed typo** i e-conomic sync endpoint: `verifiot_matched_count` → `verified_count`
|
||||
- **Tilføjet `not_matched`** til return value for bedre feedback
|
||||
|
||||
## Deployment Instructions
|
||||
|
||||
### Production Server Update
|
||||
|
||||
1. **SSH til serveren:**
|
||||
```bash
|
||||
ssh bmcadmin@172.16.31.183
|
||||
```
|
||||
|
||||
2. **Naviger til projekt directory:**
|
||||
```bash
|
||||
cd /path/to/bmc_hub # Skal opdateres til korrekt sti
|
||||
```
|
||||
|
||||
3. **Pull ny version:**
|
||||
```bash
|
||||
git pull origin main
|
||||
git checkout v1.3.5
|
||||
```
|
||||
|
||||
4. **Genstart containers:**
|
||||
```bash
|
||||
docker-compose down
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
5. **Verificer:**
|
||||
```bash
|
||||
docker ps
|
||||
curl http://localhost:8001/health
|
||||
curl http://localhost:8001/settings
|
||||
```
|
||||
|
||||
## Technical Details
|
||||
|
||||
- **Git Tag:** v1.3.5
|
||||
- **Commit:** c5ce819
|
||||
- **Changed Files:** `app/system/backend/sync_router.py`
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
Ingen breaking changes i denne release.
|
||||
|
||||
## Notes
|
||||
|
||||
Settings siden er verificeret at virke både lokalt og skal virke efter deployment på production.
|
||||
@ -104,6 +104,40 @@ async def get_setting_categories():
|
||||
return [row['category'] for row in result] if result else []
|
||||
|
||||
|
||||
@router.post("/settings/sync-from-env", tags=["Settings"])
|
||||
async def sync_settings_from_env():
|
||||
"""Sync settings from .env file into database (only updates empty values)"""
|
||||
from app.core.config import settings as env_settings
|
||||
|
||||
mapping = {
|
||||
'vtiger_enabled': str(env_settings.VTIGER_ENABLED).lower(),
|
||||
'vtiger_url': env_settings.VTIGER_URL or '',
|
||||
'vtiger_username': env_settings.VTIGER_USERNAME or '',
|
||||
'economic_enabled': str(env_settings.ECONOMIC_ENABLED).lower(),
|
||||
'economic_app_secret': env_settings.ECONOMIC_APP_SECRET_TOKEN or '',
|
||||
'economic_agreement_token': env_settings.ECONOMIC_AGREEMENT_GRANT_TOKEN or '',
|
||||
}
|
||||
|
||||
updated_count = 0
|
||||
for key, value in mapping.items():
|
||||
# Only update if current value is empty or NULL
|
||||
query = """
|
||||
UPDATE settings
|
||||
SET value = %s, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE key = %s AND (value IS NULL OR value = '')
|
||||
RETURNING key
|
||||
"""
|
||||
result = execute_query(query, (value, key))
|
||||
if result:
|
||||
updated_count += 1
|
||||
logger.info(f"✅ Synced {key} from .env")
|
||||
|
||||
return {
|
||||
"message": f"Synced {updated_count} settings from .env file",
|
||||
"updated_count": updated_count
|
||||
}
|
||||
|
||||
|
||||
# User Management Endpoints
|
||||
@router.get("/users", response_model=List[User], tags=["Users"])
|
||||
async def get_users(is_active: Optional[bool] = None):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user