Feat: rename chat

This commit is contained in:
Grail Finder
2024-11-24 17:39:52 +03:00
parent 6625a8103b
commit 5dfb558476
6 changed files with 327 additions and 249 deletions

View File

@@ -19,6 +19,7 @@ type ChatHistory interface {
GetLastChat() (*models.Chat, error)
UpsertChat(chat *models.Chat) (*models.Chat, error)
RemoveChat(id uint32) error
ChatGetMaxID() (uint32, error)
}
type ProviderSQL struct {
@@ -66,6 +67,13 @@ func (p ProviderSQL) RemoveChat(id uint32) error {
return err
}
func (p ProviderSQL) ChatGetMaxID() (uint32, error) {
query := "SELECT MAX(id) FROM chats;"
var id uint32
err := p.db.Get(&id, query)
return id, err
}
func NewProviderSQL(dbPath string, logger *slog.Logger) FullRepo {
db, err := sqlx.Open("sqlite", dbPath)
if err != nil {