73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
const { Pool } = require('pg');
|
|
|
|
async function createTestCanvas() {
|
|
const pool = new Pool({ connectionString: 'postgresql://postgres:postgres@localhost:5432/xflow' });
|
|
|
|
const nodes = [
|
|
{
|
|
id: 'task-1',
|
|
type: 'task',
|
|
x: 100, y: 100, width: 300, height: 200,
|
|
text: '# Создать API пользователей\nРазработать эндпоинт для списка пользователей',
|
|
state: 'todo',
|
|
assigned_to: 'almalexyz@gmail.com',
|
|
priority: 'high',
|
|
alarm: new Date(Date.now() + 86400000).toISOString()
|
|
},
|
|
{
|
|
id: 'task-2',
|
|
type: 'task',
|
|
x: 450, y: 100, width: 300, height: 200,
|
|
text: '# Канбан-доска\nСделать вывод всех задач',
|
|
state: 'in_progress',
|
|
assigned_to: 'almalexyz',
|
|
priority: 'medium'
|
|
},
|
|
{
|
|
id: 'task-3',
|
|
type: 'task',
|
|
x: 100, y: 350, width: 300, height: 200,
|
|
text: '# Проверка прав\nНастроить доступ к картам',
|
|
state: 'review',
|
|
assigned_to: 'almalexyz',
|
|
priority: 'high'
|
|
},
|
|
{
|
|
id: 'task-4',
|
|
type: 'task',
|
|
x: 450, y: 350, width: 300, height: 200,
|
|
text: '# Тестирование\nПроверить как работают бейджики',
|
|
state: 'todo',
|
|
assigned_to: 'system',
|
|
priority: 'low'
|
|
}
|
|
];
|
|
|
|
const canvasData = {
|
|
id: 'test-crm',
|
|
name: 'Тестовый CRM проект',
|
|
ownerId: 'system',
|
|
isPublic: true,
|
|
nodes: JSON.stringify(nodes),
|
|
edges: JSON.stringify([])
|
|
};
|
|
|
|
try {
|
|
// Upsert canvas
|
|
await pool.query(`
|
|
INSERT INTO "Canvas" (id, name, "ownerId", "isPublic", nodes, edges, "updatedAt")
|
|
VALUES ($1, $2, $3, $4, $5, $6, NOW())
|
|
ON CONFLICT (id) DO UPDATE
|
|
SET nodes = EXCLUDED.nodes, edges = EXCLUDED.edges, "updatedAt" = NOW()
|
|
`, [canvasData.id, canvasData.name, canvasData.ownerId, canvasData.isPublic, canvasData.nodes, canvasData.edges]);
|
|
|
|
console.log('Test canvas fixed successfully!');
|
|
} catch (e) {
|
|
console.error('Error:', e);
|
|
} finally {
|
|
pool.end();
|
|
}
|
|
}
|
|
|
|
createTestCanvas();
|