database changes
This commit is contained in:
@@ -17,15 +17,15 @@ type RPRepository struct {
|
||||
client *redis.Client
|
||||
}
|
||||
|
||||
func NewRPRepository(db *laniakea.DatabaseContext) *RPRepository {
|
||||
return &RPRepository{client: db.Redis}
|
||||
func NewRPRepository(db *laniakea.DatabaseContext) RPRepository {
|
||||
return RPRepository{client: db.Redis}
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetSelectedWaifu(userId, waifuId int) error {
|
||||
func (rep RPRepository) SetSelectedWaifu(userId, waifuId int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
||||
return rep.client.Set(ctx, key, waifuId, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetSelectedWaifu(userId int) int {
|
||||
func (rep RPRepository) GetSelectedWaifu(userId int) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -35,11 +35,11 @@ func (rep *RPRepository) GetSelectedWaifu(userId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetChatId(userId, waifuId int, chatId string) error {
|
||||
func (rep RPRepository) SetChatId(userId, waifuId int, chatId string) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
||||
return rep.client.Set(context.Background(), key, chatId, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetChatId(userId, waifuId int) string {
|
||||
func (rep RPRepository) GetChatId(userId, waifuId int) string {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -47,7 +47,7 @@ func (rep *RPRepository) GetChatId(userId, waifuId int) string {
|
||||
}
|
||||
return res.Val()
|
||||
}
|
||||
func (rep *RPRepository) GetOrCreateChatId(userId, waifuId int) (string, error) {
|
||||
func (rep RPRepository) GetOrCreateChatId(userId, waifuId int) (string, error) {
|
||||
chatId := rep.GetChatId(userId, waifuId)
|
||||
if chatId == "" {
|
||||
chatId = uuid.New().String()
|
||||
@@ -56,11 +56,11 @@ func (rep *RPRepository) GetOrCreateChatId(userId, waifuId int) (string, error)
|
||||
return chatId, err
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetChatPrompt(userId, waifuId int, prompt string) error {
|
||||
func (rep RPRepository) SetChatPrompt(userId, waifuId int, prompt string) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
||||
return rep.client.Set(context.Background(), key, prompt, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetChatPrompt(userId, waifuId int) string {
|
||||
func (rep RPRepository) GetChatPrompt(userId, waifuId int) string {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -69,11 +69,11 @@ func (rep *RPRepository) GetChatPrompt(userId, waifuId int) string {
|
||||
return res.Val()
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetCounter(userId, waifuId, counter int) error {
|
||||
func (rep RPRepository) SetCounter(userId, waifuId, counter int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.counter", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, counter, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetCounter(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetCounter(userId, waifuId int) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.counter", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -83,11 +83,11 @@ func (rep *RPRepository) GetCounter(userId, waifuId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetChatTokens(userId, waifuId, tokens int) error {
|
||||
func (rep RPRepository) SetChatTokens(userId, waifuId, tokens int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.tokens", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, tokens, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetChatTokens(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetChatTokens(userId, waifuId int) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.tokens", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -97,11 +97,11 @@ func (rep *RPRepository) GetChatTokens(userId, waifuId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetChatSettingID(userId, waifuId, settingId int) error {
|
||||
func (rep RPRepository) SetChatSettingID(userId, waifuId, settingId int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.setting_id", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, settingId, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetChatSettingID(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetChatSettingID(userId, waifuId int) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.setting_id", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -111,11 +111,11 @@ func (rep *RPRepository) GetChatSettingID(userId, waifuId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep *RPRepository) SetChatScenariosIDs(userId, waifuId int, scenarioIds string) error {
|
||||
func (rep RPRepository) SetChatScenariosIDs(userId, waifuId int, scenarioIds string) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.scenario_id", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, scenarioIds, 0).Err()
|
||||
}
|
||||
func (rep *RPRepository) GetChatScenariosIDs(userId, waifuId int) []int {
|
||||
func (rep RPRepository) GetChatScenariosIDs(userId, waifuId int) []int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.scenario_id", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
|
||||
Reference in New Issue
Block a user