-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_project_tasks.py
More file actions
204 lines (178 loc) · 7.68 KB
/
update_project_tasks.py
File metadata and controls
204 lines (178 loc) · 7.68 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env python3
"""
Script to update project tracker tasks to reflect the correct architecture:
OpenClaw gateway runs in WSL for direct management, while PostgreSQL database
runs in Kubernetes cluster.
"""
import os
import sys
import json
import psycopg2
import psycopg2.extras
from datetime import datetime
# PostgreSQL connection settings (same as pt/fp/seek tools)
DB_HOST = os.environ.get("PT_DB_HOST", "localhost")
DB_PORT = int(os.environ.get("PT_DB_PORT", 5433))
DB_NAME = os.environ.get("PT_DB_NAME", "financial_analysis")
DB_USER = os.environ.get("PT_DB_USER", "finance_user")
DB_PASSWORD = os.environ.get("PT_DB_PASSWORD", "secure_finance_password")
def get_connection():
"""Establish a connection to the PostgreSQL database."""
try:
conn = psycopg2.connect(
host=DB_HOST,
port=DB_PORT,
database=DB_NAME,
user=DB_USER,
password=DB_PASSWORD
)
return conn
except Exception as e:
print(f"Error connecting to PostgreSQL database: {e}")
sys.exit(1)
def list_entries(conn, project="openclaw"):
"""List all entries for the openclaw project."""
cursor = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cursor.execute("""
SELECT * FROM project_tracker
WHERE project = %s
ORDER BY created_date DESC, priority ASC NULLS LAST
""", (project,))
rows = cursor.fetchall()
print(f"Entries for project '{project}':")
print("-" * 80)
for row in rows:
print(f"ID: {row['id']}")
print(f"Category: {row['category']}")
print(f"Priority: {row['priority']}")
print(f"Status: {row['status']}")
print(f"Title: {row['title']}")
print(f"Description: {row['description'][:100] if row['description'] else ''}{'...' if row['description'] and len(row['description']) > 100 else ''}")
print(f"Tags: {row['tags']}")
print(f"Created: {row['created_date']}, Updated: {row['updated_date']}")
print("-" * 80)
return rows
def update_task_architecture(conn):
"""Update tasks to reflect the correct architecture: WSL gateway + K8s DB."""
cursor = conn.cursor()
# Get current date for updating timestamps
now_str = datetime.now()
# First, let's identify the incorrect Docker-only execution tasks
# Search for tasks that mention Docker execution or similar
cursor.execute("""
SELECT id, title, description
FROM project_tracker
WHERE project = %s
AND (title ILIKE %s OR description ILIKE %s
OR title ILIKE %s OR description ILIKE %s
OR title ILIKE %s OR description ILIKE %s)
""", ('openclaw', '%Docker%', '%Docker%', '%execution%', '%execution%', '%container%', '%container%'))
docker_related_tasks = cursor.fetchall()
print(f"Found {len(docker_related_tasks)} potentially Docker-related tasks to update/review:")
for task_row in docker_related_tasks: # Renamed 'task' to 'task_row' to avoid conflict with task dictionary later
print(f" - ID {task_row['id']}: {task_row['title']}")
# Update existing tasks that incorrectly describe the architecture
update_count = 0
# Example update for any tasks that describe incorrect Docker-only architecture
cursor.execute("""
UPDATE project_tracker
SET description = REPLACE(description, 'Docker-only execution', 'hybrid execution with WSL gateway and K8s DB'),
updated_date = %s
WHERE project = %s
AND description ILIKE %s
""", (now_str, 'openclaw', '%Docker-only%'))
update_count += cursor.rowcount
cursor.execute("""
UPDATE project_tracker
SET description = REPLACE(description, 'runs in Docker containers', 'gateway runs in WSL, database runs in Kubernetes'),
updated_date = %s
WHERE project = %s
AND description ILIKE %s
""", (now_str, 'openclaw', '%runs in Docker containers%'))
update_count += cursor.rowcount
# Now add the correct architecture tasks if they don't exist
correct_architecture_tasks = [
{
"category": "roadmap",
"title": "OpenClaw gateway runs in WSL for direct management",
"description": "Implement OpenClaw gateway to run in WSL environment for direct system management and control.",
"priority": "high",
"status": "new",
"tags": ["architecture", "gateway", "wsl"]
},
{
"category": "roadmap",
"title": "PostgreSQL database runs in Kubernetes cluster",
"description": "Deploy PostgreSQL database in Kubernetes cluster for scalability and resilience, managed separately from gateway.",
"priority": "high",
"status": "new",
"tags": ["architecture", "database", "kubernetes", "postgresql"]
},
{
"category": "roadmap",
"title": "Configure WSL-K8s communication for OpenClaw",
"description": "Set up secure communication between WSL-based OpenClaw gateway and PostgreSQL in Kubernetes cluster.",
"priority": "medium",
"status": "new",
"tags": ["networking", "communication", "configuration"]
},
{
"category": "roadmap",
"title": "Implement hybrid deployment strategy",
"description": "Create deployment scripts and documentation for the hybrid approach: gateway in WSL, DB in K8s.",
"priority": "medium",
"status": "new",
"tags": ["deployment", "documentation", "hybrid"]
}
]
# Check if these tasks already exist to avoid duplicates
for task in correct_architecture_tasks:
cursor.execute("""
SELECT COUNT(*) as count
FROM project_tracker
WHERE project = %s
AND title = %s
""", ('openclaw', task["title"]))
result = cursor.fetchone()
if result[0] == 0: # Use result[0] for count from fetchone()
cursor.execute("""
INSERT INTO project_tracker (
project, category, title, description, priority, status,
created_date, updated_date, tags
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
""", (
"openclaw",
task["category"],
task["title"],
task["description"],
task["priority"],
task["status"],
now_str, # created_date
now_str, # updated_date
json.dumps(task["tags"]) # Convert tags list to JSONB string
))
print(f"Added new task: {task['title']}")
else:
print(f"Task already exists: {task['title']}")
conn.commit()
print(f"\nUpdated {update_count} existing tasks to reflect correct architecture.")
print(f"Added new tasks reflecting the correct architecture (WSL gateway + K8s DB).")
def main():
print("Connecting to project tracker database...")
try:
conn = get_connection()
print("\nCurrent project entries:")
entries = list_entries(conn)
print(f"\nTotal entries found: {len(entries)}")
print("\nUpdating tasks to reflect correct architecture (WSL gateway + K8s DB)...")
update_task_architecture(conn)
print("\nUpdated project entries:")
list_entries(conn)
conn.close()
print("\nDatabase updated successfully!")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()