-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_shortlist_data.py
More file actions
63 lines (54 loc) · 2.59 KB
/
check_shortlist_data.py
File metadata and controls
63 lines (54 loc) · 2.59 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
"""
Quick diagnostic script to check shortlist data in database
"""
from src.config.supabase import get_supabase
def check_shortlist_data():
supabase = get_supabase()
print("=" * 60)
print("CHECKING SHORTLIST DATA")
print("=" * 60)
# Check all shortlist entries
print("\n1. All Shortlist Entries:")
shortlist = supabase.table('shortlist').select('*').execute()
print(f" Total entries: {len(shortlist.data)}")
for item in shortlist.data[:5]: # Show first 5
print(f" - ID: {item['id']}, CSR User: {item['csr_user_id']}, Request: {item['request_id']}, Status: {item['status']}")
# Check CSR users
print("\n2. CSR Users (role_id=3):")
csr_users = supabase.table('users').select('id, username, email, role_id').eq('role_id', 3).execute()
print(f" Total CSR users: {len(csr_users.data)}")
for user in csr_users.data[:5]:
print(f" - ID: {user['id']}, Username: {user['username']}, Email: {user['email']}")
# Check active requests
print("\n3. Active Requests:")
requests = supabase.table('requests').select('id, title, status').eq('status', 'ACTIVE').execute()
print(f" Total active requests: {len(requests.data)}")
for req in requests.data[:5]:
print(f" - ID: {req['id']}, Title: {req['title']}, Status: {req['status']}")
# Check shortlist with JOIN (mimics the actual query)
print("\n4. Shortlist with JOIN (like API does):")
shortlist_join = supabase.table('shortlist').select(
"*",
"requests(*)",
"users(id, username, full_name, email)"
).execute()
print(f" Total with JOIN: {len(shortlist_join.data)}")
for item in shortlist_join.data[:3]:
print(f" - Shortlist ID: {item['id']}")
print(f" CSR User: {item.get('users', {}).get('username', 'N/A')}")
print(f" Request: {item.get('requests', {}).get('title', 'N/A')}")
print(f" Status: {item['status']}")
# If you have a specific CSR user, check their shortlist
if csr_users.data:
test_csr_id = csr_users.data[0]['id']
print(f"\n5. Shortlist for CSR User ID {test_csr_id} ({csr_users.data[0]['username']}):")
user_shortlist = supabase.table('shortlist').select(
"*",
"requests(*)"
).eq('csr_user_id', test_csr_id).execute()
print(f" Items: {len(user_shortlist.data)}")
for item in user_shortlist.data:
print(f" - {item.get('requests', {}).get('title', 'N/A')} (Status: {item['status']})")
print("\n" + "=" * 60)
if __name__ == '__main__':
check_shortlist_data()