Changeset 0.29.0 (#195)
This commit is contained in:
@@ -254,3 +254,34 @@ func (s *MemoryStore) 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 = ? WHERE id = ?`, 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 = ? AND user_id = ?`,
|
||||
channelID, userID).Scan(&lastID)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
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 (id, channel_id, user_id, last_message_id, memory_count)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
ON CONFLICT(channel_id, user_id) DO UPDATE SET
|
||||
last_message_id = excluded.last_message_id,
|
||||
extracted_at = datetime('now'),
|
||||
memory_count = memory_extraction_log.memory_count + excluded.memory_count
|
||||
`, store.NewID(), channelID, userID, lastMessageID, count)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user