HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/af/scripts/analyze_awp_posts.py
#!/usr/bin/env python3
"""
Temporäres Skript zur Analyse der awp_posts-Tabelle.
"""

import os
import sys
from dotenv import load_dotenv

# Füge das Hauptverzeichnis zum Python-Pfad hinzu
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

# Lade Umgebungsvariablen
load_dotenv()

from src.database.operations import execute_select_query, get_table_schema

def analyze_awp_posts():
    """Analysiert die Struktur der awp_posts-Tabelle und gibt einen Beispieldatensatz zurück."""
    
    print("=== Analysiere awp_posts-Tabelle ===")
    
    # Schema der Tabelle abrufen
    schema = get_table_schema('awp_posts')
    if not schema:
        print("Fehler: Konnte das Schema der awp_posts-Tabelle nicht abrufen.")
        return
    
    print("Schema der awp_posts-Tabelle:")
    for col, typ in schema.items():
        print(f"  - {col}: {typ}")
    
    # Beispieldaten abrufen
    query = """
    SELECT * 
    FROM awp_posts 
    WHERE post_status = 'publish' 
    ORDER BY post_date DESC 
    LIMIT 1
    """
    
    result = execute_select_query(query, return_type='dict')
    
    if not result or len(result) == 0:
        print("Keine Daten in der awp_posts-Tabelle gefunden.")
        return
    
    print("\nBeispieldatensatz:")
    post = result[0]
    for key, value in post.items():
        # Limitiere die Ausgabe für längere Felder
        if isinstance(value, str) and len(value) > 100:
            value = value[:100] + "..."
        print(f"  - {key}: {value}")
    
    # Spezifisch nach post_type-Werten suchen
    query_types = """
    SELECT DISTINCT post_type, COUNT(*) as count
    FROM awp_posts
    WHERE post_status = 'publish'
    GROUP BY post_type
    ORDER BY count DESC
    """
    
    type_results = execute_select_query(query_types, return_type='dict')
    
    if type_results and len(type_results) > 0:
        print("\nVerfügbare post_types und Anzahl:")
        for item in type_results:
            print(f"  - {item['post_type']}: {item['count']}")

if __name__ == "__main__":
    analyze_awp_posts()