* Store a Slack message for local search * Uses upsert to avoid duplicates based on channel_id + ts
(input: SlackMessageInput)
| 414 | * Uses upsert to avoid duplicates based on channel_id + ts |
| 415 | */ |
| 416 | async indexSlackMessage(input: SlackMessageInput): Promise<void> { |
| 417 | // Create a title from the first 100 chars of the message |
| 418 | const title = input.text.substring(0, 100) + (input.text.length > 100 ? '...' : ''); |
| 419 | |
| 420 | await query( |
| 421 | `INSERT INTO addie_knowledge ( |
| 422 | title, category, content, source_url, source_type, |
| 423 | slack_channel_id, slack_channel_name, slack_user_id, slack_username, slack_ts, slack_permalink, |
| 424 | created_by |
| 425 | ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) |
| 426 | ON CONFLICT (slack_channel_id, slack_ts) WHERE source_type = 'slack' |
| 427 | DO UPDATE SET |
| 428 | content = EXCLUDED.content, |
| 429 | title = EXCLUDED.title, |
| 430 | slack_username = EXCLUDED.slack_username, |
| 431 | updated_at = NOW()`, |
| 432 | [ |
| 433 | title, |
| 434 | 'slack', |
| 435 | input.text, |
| 436 | input.permalink, |
| 437 | 'slack', |
| 438 | input.channel_id, |
| 439 | input.channel_name, |
| 440 | input.user_id, |
| 441 | input.username, |
| 442 | input.ts, |
| 443 | input.permalink, |
| 444 | 'system', |
| 445 | ] |
| 446 | ); |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Search Slack messages stored locally using PostgreSQL full-text search |
no test coverage detected