-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_consistency.py
More file actions
164 lines (130 loc) · 5.86 KB
/
validate_consistency.py
File metadata and controls
164 lines (130 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python3
import re
import os
import json
from pathlib import Path
def validate_html_consistency():
"""Validate that all HTML files have consistent metrics"""
# Load expected metrics
with open('filtered_dataset_metrics.json', 'r') as f:
expected_metrics = json.load(f)
print("=== VALIDATING METRICS CONSISTENCY ACROSS ALL REPORTS ===\n")
print(f"Expected metrics from filtered dataset:")
print(f" Total Reviews: {expected_metrics['total_reviews']:,}")
print(f" Data Currency: {expected_metrics['data_currency']}%")
print(f" Average Rating: {expected_metrics['average_rating']}")
print(f" Rogers: {expected_metrics['rogers_reviews']:,} ({expected_metrics['rogers_percentage']}%)")
print(f" Bell: {expected_metrics['bell_reviews']:,} ({expected_metrics['bell_percentage']}%)\n")
# Files to validate
html_files = [
'html_dashboard/dashboard.html',
'html_dashboard/executive_summary.html',
'html_dashboard/rogers_cx_transformation_report.html',
'html_dashboard/bell_smart_cx_report.html',
'html_dashboard/cx_ux_assessment_report.html',
'html_dashboard/metrics_calculations_verification.html',
'html_dashboard/research_process_approach.html',
'html_dashboard/key_metrics_reference.html'
]
issues = []
for html_file in html_files:
if not os.path.exists(html_file):
issues.append(f"❌ File not found: {html_file}")
continue
print(f"📄 Validating {html_file}...")
with open(html_file, 'r', encoding='utf-8') as f:
content = f.read()
file_issues = []
# Check for old review counts
old_counts = ['12,785', '12,893', '12785', '12893']
for old_count in old_counts:
if old_count in content:
file_issues.append(f" ❌ Still contains old count: {old_count}")
# Check for correct total review count
if '10,103' not in content:
file_issues.append(f" ⚠️ Missing correct total review count (10,103)")
# Check data timeframe
if '2010' in content and '2020-2025' not in content:
file_issues.append(f" ⚠️ May contain old timeframe (2010 instead of 2020)")
# Check for old data currency percentages
old_currency = ['65.2%', '78.4%']
for old_perc in old_currency:
if old_perc in content:
file_issues.append(f" ❌ Still contains old data currency: {old_perc}")
# Check for correct data currency
if '99.6%' not in content and 'data_accuracy_report' not in html_file:
file_issues.append(f" ⚠️ Missing correct data currency (99.6%)")
if file_issues:
issues.extend([f"Issues in {html_file}:"] + file_issues)
print(f" ❌ Found {len(file_issues)} issues")
else:
print(f" ✅ All metrics consistent")
print()
# Validate dashboard data files
print("📊 Validating dashboard data files...")
js_files = [
'html_dashboard/dashboard_complete_enhanced.js',
'html_dashboard/dashboard_final.js'
]
for js_file in js_files:
if os.path.exists(js_file):
with open(js_file, 'r', encoding='utf-8') as f:
js_content = f.read()
if 'total_reviews: 10103' in js_content:
print(f" ✅ {js_file} has correct total_reviews")
else:
issues.append(f"❌ {js_file} missing correct total_reviews")
else:
issues.append(f"❌ JS file not found: {js_file}")
print()
# Summary
if issues:
print("=== VALIDATION ISSUES FOUND ===")
for issue in issues:
print(issue)
print(f"\nTotal issues: {len(issues)}")
else:
print("=== VALIDATION PASSED ===")
print("✅ All files have consistent metrics matching the filtered dataset")
print("✅ Dashboard data files are synchronized")
print("✅ All reports reflect 10,103 reviews from 2020-2025")
print("✅ Data currency improved to 99.6%")
return len(issues) == 0
def validate_dashboard_functionality():
"""Quick validation of dashboard HTML structure"""
print("\n=== VALIDATING DASHBOARD FUNCTIONALITY ===")
dashboard_file = 'html_dashboard/dashboard.html'
if not os.path.exists(dashboard_file):
print("❌ Dashboard file not found")
return False
with open(dashboard_file, 'r', encoding='utf-8') as f:
content = f.read()
checks = [
('Chart.js library', 'chart.js'),
('Plotly library', 'plotly.js'),
('Dashboard initialization', 'initializeStandaloneMode'),
('Chart containers', 'sentiment-chart'),
('Navigation tabs', 'nav-tab'),
('Loading screen', 'loading'),
('Updated total reviews', '10,103')
]
all_passed = True
for check_name, check_pattern in checks:
if check_pattern in content:
print(f" ✅ {check_name}")
else:
print(f" ❌ {check_name}")
all_passed = False
return all_passed
if __name__ == "__main__":
consistency_ok = validate_html_consistency()
functionality_ok = validate_dashboard_functionality()
print(f"\n=== FINAL VALIDATION RESULTS ===")
if consistency_ok and functionality_ok:
print("🎉 ALL VALIDATIONS PASSED!")
print(" • Metrics are consistent across all reports")
print(" • Dashboard functionality is intact")
print(" • Filtered dataset properly reflected (10,103 reviews)")
print(" • Data currency improved to 99.6%")
else:
print("⚠️ Some validations failed - please review the issues above")