Changeset 0.29.0 (#195)
This commit is contained in:
@@ -270,3 +270,34 @@ func scanMemories(rows *sql.Rows) ([]models.Memory, error) {
|
||||
|
||||
// ensure compile-time interface satisfaction
|
||||
var _ store.MemoryStore = (*MemoryStore)(nil)
|
||||
|
||||
// ── CS5b additions (v0.29.0) ────────────────────────────────────────────
|
||||
|
||||
func (s *MemoryStore) SetEmbedding(ctx context.Context, id, embedding string) error {
|
||||
_, err := DB.ExecContext(ctx,
|
||||
`UPDATE memories SET embedding = $1::vector WHERE id = $2`, embedding, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *MemoryStore) GetLastExtractionMessageID(ctx context.Context, channelID, userID string) (string, error) {
|
||||
var lastID string
|
||||
err := DB.QueryRowContext(ctx,
|
||||
`SELECT last_message_id FROM memory_extraction_log WHERE channel_id = $1 AND user_id = $2`,
|
||||
channelID, userID).Scan(&lastID)
|
||||
if err != nil {
|
||||
return "", nil // no entry yet
|
||||
}
|
||||
return lastID, nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) UpsertExtractionLog(ctx context.Context, channelID, userID, lastMessageID string, count int) error {
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
INSERT INTO memory_extraction_log (channel_id, user_id, last_message_id, memory_count)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT(channel_id, user_id) DO UPDATE SET
|
||||
last_message_id = EXCLUDED.last_message_id,
|
||||
extracted_at = now(),
|
||||
memory_count = memory_extraction_log.memory_count + EXCLUDED.memory_count
|
||||
`, channelID, userID, lastMessageID, count)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user