70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Verification script for the analytics dashboard FieldError fix.
|
|
This verifies that the problematic query has been corrected.
|
|
"""
|
|
import re
|
|
|
|
def check_ui_views_fix():
|
|
"""Check that ui_views.py has been fixed"""
|
|
print("Checking apps/analytics/ui_views.py for the fix...")
|
|
|
|
with open('apps/analytics/ui_views.py', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Check for the problematic pattern
|
|
if 'response__survey_instance' in content:
|
|
print("❌ Found problematic 'response__survey_instance' lookup")
|
|
return False
|
|
|
|
# Check for the corrected pattern
|
|
if 'response__survey_responses__survey_instance' in content:
|
|
print("✅ Found corrected 'response__survey_responses__survey_instance' lookup")
|
|
return True
|
|
|
|
# Alternative check - make sure the query uses survey_responses
|
|
if 'survey_responses' in content and 'response__' in content:
|
|
print("✅ Query uses survey_responses properly")
|
|
return True
|
|
|
|
print("⚠️ Could not definitively confirm the fix")
|
|
return False
|
|
|
|
def check_migration_fix():
|
|
"""Check that migration dependencies are correct"""
|
|
print("\nChecking migration dependencies...")
|
|
|
|
with open('apps/analytics/migrations/0005_kpireport_kpireportmonthlydata_kpireportdepartmentbreakdown_kpireportsourcebreakdown.py', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Check for dependencies
|
|
if 'dependencies = [' in content:
|
|
print("✅ Migration has dependencies defined")
|
|
return True
|
|
|
|
print("❌ Migration missing dependencies")
|
|
return False
|
|
|
|
def main():
|
|
print("=" * 60)
|
|
print("Analytics Dashboard FieldError Fix Verification")
|
|
print("=" * 60)
|
|
|
|
ui_fixed = check_ui_views_fix()
|
|
migration_ok = check_migration_fix()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("Summary:")
|
|
print("=" * 60)
|
|
print(f"ui_views.py fix: {'✅ PASS' if ui_fixed else '❌ FAIL'}")
|
|
print(f"Migration fix: {'✅ PASS' if migration_ok else '❌ FAIL'}")
|
|
|
|
if ui_fixed and migration_ok:
|
|
print("\n🎉 All checks passed! The FieldError should be resolved.")
|
|
return 0
|
|
else:
|
|
print("\n❌ Some checks failed. Please review the implementation.")
|
|
return 1
|
|
|
|
if __name__ == '__main__':
|
|
exit(main()) |