🔧 Fix machine connectivity and pharmacy display issues

- Fix database initialization to use correct Headscale DB path
- Implement proper data synchronization between Headscale and FARMQ
- Resolve timezone comparison error in machine online status detection
- Update machine listing to use actual Headscale Node data instead of MachineProfile
- Add proper pharmacy-to-machine mapping display
- Show both technical Headscale usernames and actual pharmacy business names
- Fix machine offline status display - now correctly shows online machines
- Add humanize_datetime utility function for better timestamp display

All machines now correctly display:
- Online status (matching actual Headscale status)
- Technical username (myuser)
- Actual pharmacy name (세종온누리약국)
- Manager name and business details

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-09 17:56:38 +09:00
parent ca61a89739
commit 1ea11a6a3c
2 changed files with 79 additions and 22 deletions

View File

@@ -9,7 +9,7 @@ import os
from datetime import datetime
from config import config
from utils.database_new import (
init_database, get_session, close_session,
init_databases, get_farmq_session,
get_dashboard_stats, get_all_pharmacies_with_stats, get_all_machines_with_details,
get_machine_detail, get_pharmacy_detail, get_active_alerts,
sync_machines_from_headscale, sync_users_from_headscale
@@ -24,12 +24,14 @@ def create_app(config_name=None):
app.config.from_object(config[config_name])
# 데이터베이스 초기화
init_database(app.config['SQLALCHEMY_DATABASE_URI'])
init_databases(
headscale_db_uri='sqlite:////srv/headscale-setup/data/db.sqlite',
farmq_db_uri='sqlite:///farmq.db'
)
# 요청 종료 후 세션 정리
@app.teardown_appcontext
def cleanup(error):
close_session()
# 데이터 동기화 실행
sync_users_from_headscale()
sync_machines_from_headscale()
# 메인 대시보드
@app.route('/')