Files
quality_app/old code/IMPROVEMENTS_APPLIED.md
2025-11-26 22:00:44 +02:00

3.6 KiB

Improvements Applied to Quality App

Date: November 13, 2025

Overview

All improvements from the production environment have been successfully transposed to the quality_app project.

Files Updated/Copied

1. Docker Configuration

  • Dockerfile - Added mariadb-client package for backup functionality
  • docker-compose.yml - Updated with proper volume mappings and /data folder support
  • .env - Updated all paths to use absolute paths under /srv/quality_app/

2. Backup & Restore System

  • database_backup.py - Fixed backup/restore functions:
    • Changed result_success to result.returncode == 0
    • Added --skip-ssl flag for MariaDB connections
    • Fixed restore function error handling
  • restore_database.sh - Fixed SQL file parsing to handle MariaDB dump format

3. UI Improvements - Sticky Table Headers

  • base.css - Added sticky header CSS for all report tables
  • scan.html - Wrapped table in report-table-container div
  • fg_scan.html - Wrapped table in report-table-container div

4. Quality Code Display Enhancement

  • fg_quality.js - Quality code 0 displays as "OK" in green; CSV exports as "0"
  • script.js - Same improvements for quality module reports

Directory Structure

/srv/quality_app/
├── py_app/              # Application code (mapped to /app in container)
├── data/
│   └── mariadb/         # Database files
├── config/
│   └── instance/        # Application configuration
├── logs/                # Application logs
├── backups/             # Database backups
├── docker-compose.yml
├── Dockerfile
├── .env
└── restore_database.sh

Environment Configuration

Volume Mappings in .env:

DB_DATA_PATH=/srv/quality_app/data/mariadb
APP_CODE_PATH=/srv/quality_app/py_app
LOGS_PATH=/srv/quality_app/logs
INSTANCE_PATH=/srv/quality_app/config/instance
BACKUP_PATH=/srv/quality_app/backups

Features Implemented

Backup System

  • Automatic scheduled backups
  • Manual backup creation
  • Data-only backups
  • Backup retention policies
  • MariaDB client tools installed

Restore System

  • Python-based restore function
  • Shell script restore with proper SQL parsing
  • Handles MariaDB dump format correctly

UI Enhancements

  • Sticky Headers: Table headers remain fixed when scrolling
  • Quality Code Display:
    • Shows "OK" in green for quality code 0
    • Exports "0" in CSV files
    • Better user experience

Volume Mapping

  • All volumes use absolute paths
  • Support for /data folder mapping
  • Easy to configure backup location on different drives

Starting the Application

cd /srv/quality_app
docker compose up -d --build

Testing Backup & Restore

Create Backup:

cd /srv/quality_app
docker compose exec web bash -c "cd /app && python3 -c 'from app import create_app; from app.database_backup import DatabaseBackupManager; app = create_app(); 
with app.app_context(): bm = DatabaseBackupManager(); result = bm.create_backup(); print(result)'"

Restore Backup:

cd /srv/quality_app
./restore_database.sh /srv/quality_app/backups/backup_file.sql

Notes

  • Database initialization is set to false (already initialized)
  • All improvements are production-ready
  • Backup path can be changed to external drive if needed
  • Application port: 8781 (default)

Next Steps

  1. Review .env file and update passwords if needed
  2. Test all functionality after deployment
  3. Configure backup schedule if needed
  4. Set up external backup drive if desired

Compatibility: All changes are backward compatible with existing data. Status: Ready for deployment