#!/usr/bin/env python
"""
Script to replace all reports_service references with simple_reports_service
"""

def fix_reports_service():
    with open('reports/views.py', 'r', encoding='utf-8') as f:
        content = f.read()
    
    # Replace all instances of reports_service with simple_reports_service
    # but avoid replacing the import line
    lines = content.split('\n')
    fixed_lines = []
    
    for line in lines:
        if 'from .simple_reports_service import simple_reports_service' in line:
            # Keep the import line as is
            fixed_lines.append(line)
        elif 'reports_service' in line:
            # Replace reports_service with simple_reports_service
            fixed_line = line.replace('reports_service', 'simple_reports_service')
            fixed_lines.append(fixed_line)
        else:
            fixed_lines.append(line)
    
    # Write back the fixed content
    with open('reports/views.py', 'w', encoding='utf-8') as f:
        f.write('\n'.join(fixed_lines))
    
    print("Fixed all reports_service references!")

if __name__ == '__main__':
    fix_reports_service()