141 lines
5.6 KiB
Python
141 lines
5.6 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
import os
|
|||
|
|
import sys
|
|||
|
|
import django
|
|||
|
|
|
|||
|
|
# プロジェクト設定
|
|||
|
|
sys.path.append('/app')
|
|||
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
|||
|
|
django.setup()
|
|||
|
|
|
|||
|
|
from django.db import connection
|
|||
|
|
import logging
|
|||
|
|
|
|||
|
|
# ログ設定
|
|||
|
|
logging.basicConfig(level=logging.INFO)
|
|||
|
|
logger = logging.getLogger(__name__)
|
|||
|
|
|
|||
|
|
def investigate_team_table_structure():
|
|||
|
|
"""チームテーブルの構造とFC岐阜問題を調査"""
|
|||
|
|
|
|||
|
|
print("=== Team テーブル構造とFC岐阜問題調査 ===")
|
|||
|
|
|
|||
|
|
with connection.cursor() as cursor:
|
|||
|
|
# 1. rog_teamテーブルの構造確認
|
|||
|
|
print("\n1. rog_teamテーブル構造:")
|
|||
|
|
cursor.execute("""
|
|||
|
|
SELECT column_name, data_type, is_nullable
|
|||
|
|
FROM information_schema.columns
|
|||
|
|
WHERE table_name = 'rog_team'
|
|||
|
|
ORDER BY ordinal_position;
|
|||
|
|
""")
|
|||
|
|
columns = cursor.fetchall()
|
|||
|
|
for col in columns:
|
|||
|
|
print(f" - {col[0]}: {col[1]} ({'NULL' if col[2] == 'YES' else 'NOT NULL'})")
|
|||
|
|
|
|||
|
|
# 2. rog_teamテーブルの総件数
|
|||
|
|
print("\n2. rog_teamテーブルの状況:")
|
|||
|
|
cursor.execute("SELECT COUNT(*) FROM rog_team;")
|
|||
|
|
total_teams = cursor.fetchone()[0]
|
|||
|
|
print(f" 総チーム数: {total_teams}")
|
|||
|
|
|
|||
|
|
# 3. FC岐阜イベント(ID:10)の詳細調査
|
|||
|
|
print("\n3. FC岐阜イベント(ID:10)詳細調査:")
|
|||
|
|
cursor.execute("SELECT COUNT(*) FROM rog_entry WHERE event_id = 10;")
|
|||
|
|
fc_entries = cursor.fetchone()[0]
|
|||
|
|
print(f" FC岐阜イベントエントリー数: {fc_entries}")
|
|||
|
|
|
|||
|
|
# 4. FC岐阜エントリーのサンプル表示
|
|||
|
|
print("\n4. FC岐阜エントリーサンプル:")
|
|||
|
|
cursor.execute("""
|
|||
|
|
SELECT id, team_id, event_id, date
|
|||
|
|
FROM rog_entry
|
|||
|
|
WHERE event_id = 10
|
|||
|
|
LIMIT 10;
|
|||
|
|
""")
|
|||
|
|
fc_entry_samples = cursor.fetchall()
|
|||
|
|
for entry in fc_entry_samples:
|
|||
|
|
print(f" Entry ID:{entry[0]}, Team ID:{entry[1]}, Event ID:{entry[2]}, Date:{entry[3]}")
|
|||
|
|
|
|||
|
|
# 5. FC岐阜エントリーのteam_idを調べる
|
|||
|
|
print("\n5. FC岐阜エントリーのteam_id分析:")
|
|||
|
|
cursor.execute("""
|
|||
|
|
SELECT team_id, COUNT(*) as count
|
|||
|
|
FROM rog_entry
|
|||
|
|
WHERE event_id = 10
|
|||
|
|
GROUP BY team_id
|
|||
|
|
ORDER BY count DESC;
|
|||
|
|
""")
|
|||
|
|
team_id_stats = cursor.fetchall()
|
|||
|
|
for stat in team_id_stats:
|
|||
|
|
print(f" Team ID:{stat[0]}, エントリー数:{stat[1]}")
|
|||
|
|
|
|||
|
|
# 6. 実際のteam_idでチーム情報を確認
|
|||
|
|
print("\n6. 実際のチーム情報確認:")
|
|||
|
|
if team_id_stats:
|
|||
|
|
sample_team_ids = [stat[0] for stat in team_id_stats[:5]]
|
|||
|
|
for team_id in sample_team_ids:
|
|||
|
|
cursor.execute("SELECT * FROM rog_team WHERE id = %s;", [team_id])
|
|||
|
|
team_info = cursor.fetchone()
|
|||
|
|
if team_info:
|
|||
|
|
print(f" Team ID:{team_id} 存在する: {team_info}")
|
|||
|
|
else:
|
|||
|
|
print(f" Team ID:{team_id} 存在しない")
|
|||
|
|
|
|||
|
|
# 7. ゼッケン番号付きチームの確認(実際のカラム名を使用)
|
|||
|
|
print("\n7. ゼッケン番号関連調査:")
|
|||
|
|
if 'zekken_number' in [col[0] for col in columns]:
|
|||
|
|
cursor.execute("""
|
|||
|
|
SELECT COUNT(*)
|
|||
|
|
FROM rog_team
|
|||
|
|
WHERE zekken_number IS NOT NULL AND zekken_number != '';
|
|||
|
|
""")
|
|||
|
|
zekken_count = cursor.fetchone()[0]
|
|||
|
|
print(f" ゼッケン番号付きチーム数: {zekken_count}")
|
|||
|
|
|
|||
|
|
if zekken_count > 0:
|
|||
|
|
cursor.execute("""
|
|||
|
|
SELECT id, zekken_number, event_id
|
|||
|
|
FROM rog_team
|
|||
|
|
WHERE zekken_number IS NOT NULL AND zekken_number != ''
|
|||
|
|
LIMIT 10;
|
|||
|
|
""")
|
|||
|
|
zekken_teams = cursor.fetchall()
|
|||
|
|
print(" ゼッケン番号付きチームサンプル:")
|
|||
|
|
for team in zekken_teams:
|
|||
|
|
print(f" Team ID:{team[0]}, Zekken:{team[1]}, Event ID:{team[2]}")
|
|||
|
|
|
|||
|
|
# 8. 通過審査管理画面の問題の原因を特定
|
|||
|
|
print("\n8. 通過審査管理画面問題の分析:")
|
|||
|
|
print(" FC岐阜イベント(ID:10)について:")
|
|||
|
|
print(f" - エントリー数: {fc_entries}")
|
|||
|
|
print(f" - 関連チーム情報の確認が必要")
|
|||
|
|
|
|||
|
|
# 実際に存在するチームを探す
|
|||
|
|
if team_id_stats:
|
|||
|
|
existing_teams = []
|
|||
|
|
missing_teams = []
|
|||
|
|
for team_id, count in team_id_stats:
|
|||
|
|
cursor.execute("SELECT COUNT(*) FROM rog_team WHERE id = %s;", [team_id])
|
|||
|
|
exists = cursor.fetchone()[0] > 0
|
|||
|
|
if exists:
|
|||
|
|
existing_teams.append((team_id, count))
|
|||
|
|
else:
|
|||
|
|
missing_teams.append((team_id, count))
|
|||
|
|
|
|||
|
|
print(f" - 存在するチーム: {len(existing_teams)}")
|
|||
|
|
print(f" - 存在しないチーム: {len(missing_teams)}")
|
|||
|
|
|
|||
|
|
if missing_teams:
|
|||
|
|
print(" 🔴 問題発見: エントリーが参照するチームが存在しない!")
|
|||
|
|
for team_id, count in missing_teams[:3]:
|
|||
|
|
print(f" Missing Team ID:{team_id} ({count}エントリー)")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
try:
|
|||
|
|
investigate_team_table_structure()
|
|||
|
|
except Exception as e:
|
|||
|
|
print(f"❌ エラーが発生しました: {e}")
|
|||
|
|
import traceback
|
|||
|
|
traceback.print_exc()
|