Update app.js
Browse files
app.js
CHANGED
|
@@ -240,7 +240,7 @@ app.post('/onboarding/create', validateRequest, async (req, res) => {
|
|
| 240 |
const isFailure = gradingResult.feasibility < 30 || gradingResult.rating === 'F';
|
| 241 |
|
| 242 |
if (!isFailure) {
|
| 243 |
-
|
| 244 |
await supabase.from('projects').insert({
|
| 245 |
id: projectId,
|
| 246 |
user_id: userId,
|
|
@@ -259,6 +259,31 @@ app.post('/onboarding/create', validateRequest, async (req, res) => {
|
|
| 259 |
userId,
|
| 260 |
status: "initializing"
|
| 261 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
// --- AUTO-START BACKGROUND INITIALIZATION ---
|
| 264 |
runBackgroundInitialization(projectId, userId, description);
|
|
|
|
| 240 |
const isFailure = gradingResult.feasibility < 30 || gradingResult.rating === 'F';
|
| 241 |
|
| 242 |
if (!isFailure) {
|
| 243 |
+
/* // DB Insert
|
| 244 |
await supabase.from('projects').insert({
|
| 245 |
id: projectId,
|
| 246 |
user_id: userId,
|
|
|
|
| 259 |
userId,
|
| 260 |
status: "initializing"
|
| 261 |
});
|
| 262 |
+
*/
|
| 263 |
+
const { error: insertError } = await supabase.from('projects').insert({
|
| 264 |
+
id: projectId,
|
| 265 |
+
user_id: userId,
|
| 266 |
+
info: {
|
| 267 |
+
title: gradingResult.title || "Untitled",
|
| 268 |
+
stats: gradingResult,
|
| 269 |
+
description,
|
| 270 |
+
answers,
|
| 271 |
+
status: "initializing"
|
| 272 |
+
}
|
| 273 |
+
});
|
| 274 |
+
|
| 275 |
+
if (insertError) {
|
| 276 |
+
console.error("Failed to insert project:", insertError.message);
|
| 277 |
+
return res.status(500).json({ error: "Database save failed" });
|
| 278 |
+
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
// NOW update local state
|
| 282 |
+
await StateManager.updateProject(projectId, {
|
| 283 |
+
title: gradingResult.title,
|
| 284 |
+
userId,
|
| 285 |
+
status: "initializing"
|
| 286 |
+
});
|
| 287 |
|
| 288 |
// --- AUTO-START BACKGROUND INITIALIZATION ---
|
| 289 |
runBackgroundInitialization(projectId, userId, description);
|