SuperCoder/internal/db/sql/sessions.sql
Kujtim Hoxha 3e424754b4
Improve summary to keep context (#159)
* improve summary to keep context

* improve loop

* remove debug msg
2025-05-15 15:59:18 +02:00

51 lines
789 B
SQL

-- name: CreateSession :one
INSERT INTO sessions (
id,
parent_session_id,
title,
message_count,
prompt_tokens,
completion_tokens,
cost,
summary_message_id,
updated_at,
created_at
) VALUES (
?,
?,
?,
?,
?,
?,
?,
null,
strftime('%s', 'now'),
strftime('%s', 'now')
) RETURNING *;
-- name: GetSessionByID :one
SELECT *
FROM sessions
WHERE id = ? LIMIT 1;
-- name: ListSessions :many
SELECT *
FROM sessions
WHERE parent_session_id is NULL
ORDER BY created_at DESC;
-- name: UpdateSession :one
UPDATE sessions
SET
title = ?,
prompt_tokens = ?,
completion_tokens = ?,
summary_message_id = ?,
cost = ?
WHERE id = ?
RETURNING *;
-- name: DeleteSession :exec
DELETE FROM sessions
WHERE id = ?;