Compare commits
No commits in common. "44ebfe4fd2aaf84684b81a9126b5ebc1282dddc9" and "672fdbcaafd48d79c0e7e70c2f0ab98f5647c79f" have entirely different histories.
44ebfe4fd2
...
672fdbcaaf
7 changed files with 3 additions and 180 deletions
|
@ -23,7 +23,6 @@ type MuffinConfig struct {
|
|||
Bot botConfig
|
||||
Train trainConfig
|
||||
DatabaseURL string
|
||||
DBName string
|
||||
}
|
||||
|
||||
func loadConfig() *MuffinConfig {
|
||||
|
@ -58,7 +57,6 @@ func setConfig(config *MuffinConfig) {
|
|||
config.Train.UserID = getValue("TRAIN_USER_ID")
|
||||
|
||||
config.DatabaseURL = getRequiredValue("DATABASE_URL")
|
||||
config.DBName = getRequiredValue("DATABASE_NAME")
|
||||
}
|
||||
|
||||
var Config *MuffinConfig = loadConfig()
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"git.wh64.net/muffin/goMuffin/utils"
|
||||
)
|
||||
|
||||
const MUFFIN_VERSION = "5.0.0-gopher_preview.250408a"
|
||||
const MUFFIN_VERSION = "5.0.0-gopher_preview.250407a"
|
||||
|
||||
var updatedString string = utils.Decimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package databases
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.wh64.net/muffin/goMuffin/configs"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
)
|
||||
|
@ -23,4 +22,4 @@ type Learn struct {
|
|||
CreatedAt time.Time `bson:"created_at"`
|
||||
}
|
||||
|
||||
var Learns *mongo.Collection = Client.Database(configs.Config.DBName).Collection("learn")
|
||||
var Learns *mongo.Collection = Client.Database("muffin_ai_test").Collection("learn")
|
||||
|
|
|
@ -3,7 +3,6 @@ package databases
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.wh64.net/muffin/goMuffin/configs"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
)
|
||||
|
@ -21,4 +20,4 @@ type Text struct {
|
|||
CreatedAt time.Time `bson:"created_at"`
|
||||
}
|
||||
|
||||
var Texts *mongo.Collection = Client.Database(configs.Config.DBName).Collection("text")
|
||||
var Texts *mongo.Collection = Client.Database("muffin_ai_test").Collection("text")
|
||||
|
|
2
go.mod
2
go.mod
|
@ -5,13 +5,11 @@ go 1.24.1
|
|||
require (
|
||||
github.com/LoperLee/golang-hangul-toolkit v1.1.0
|
||||
github.com/bwmarrin/discordgo v0.28.1
|
||||
github.com/go-sql-driver/mysql v1.9.2
|
||||
github.com/joho/godotenv v1.5.1
|
||||
go.mongodb.org/mongo-driver/v2 v2.1.0
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/golang/snappy v1.0.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,13 +1,9 @@
|
|||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/LoperLee/golang-hangul-toolkit v1.1.0 h1:JEyLpLyA2hDQwWY9oCprHClnKIdkYVOSJzAat2uFX/A=
|
||||
github.com/LoperLee/golang-hangul-toolkit v1.1.0/go.mod h1:CDbZ23/IL4v2ovWIOb7xDEiFcSc0pIIbbYTpg+gP+Sk=
|
||||
github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4=
|
||||
github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
||||
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
|
||||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.wh64.net/muffin/goMuffin/configs"
|
||||
"git.wh64.net/muffin/goMuffin/databases"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// 이 스크립트는 MariaDB -> MongoDB로의 전환을 위해 만들었음.
|
||||
func main() {
|
||||
mariaURL := os.Getenv("PREVIOUS_DATABASE_URL")
|
||||
mongoURL := configs.Config.DatabaseURL
|
||||
|
||||
dbConnectionQuery := "?parseTime=true"
|
||||
|
||||
wg.Add(3)
|
||||
|
||||
// statement -> text
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
var text, persona string
|
||||
var createdAt time.Time
|
||||
mariaDB, err := sql.Open("mysql", mariaURL+dbConnectionQuery)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mongoDB, err := mongo.Connect(options.Client().ApplyURI(mongoURL))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer mongoDB.Disconnect(context.TODO())
|
||||
defer mariaDB.Close()
|
||||
rows, err := mariaDB.Query("select text, persona, created_at from statement;")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
|
||||
i := 1
|
||||
|
||||
for rows.Next() {
|
||||
fmt.Printf("statement %d\n", i)
|
||||
err = rows.Scan(&text, &persona, &createdAt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if text == "" {
|
||||
text = "살ㄹ려주세요"
|
||||
}
|
||||
databases.Texts.InsertOne(context.TODO(), databases.InsertText{
|
||||
Text: text,
|
||||
Persona: persona,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
i++
|
||||
}
|
||||
}()
|
||||
|
||||
// nsfw_content -> text
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
var text, persona string
|
||||
var createdAt time.Time
|
||||
mariaDB, err := sql.Open("mysql", mariaURL+dbConnectionQuery)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mongoDB, err := mongo.Connect(options.Client().ApplyURI(mongoURL))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer mongoDB.Disconnect(context.TODO())
|
||||
defer mariaDB.Close()
|
||||
rows, err := mariaDB.Query("select text, persona, created_at from nsfw_content;")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
|
||||
i := 1
|
||||
|
||||
for rows.Next() {
|
||||
fmt.Printf("nsfw_content %d\n", i)
|
||||
err = rows.Scan(&text, &persona, &createdAt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if text == "" {
|
||||
text = "살ㄹ려주세요"
|
||||
}
|
||||
databases.Texts.InsertOne(context.TODO(), databases.InsertText{
|
||||
Text: text,
|
||||
Persona: persona,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
i++
|
||||
}
|
||||
}()
|
||||
|
||||
// learn -> learn
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
var command, result, userId string
|
||||
var createdAt time.Time
|
||||
mariaDB, err := sql.Open("mysql", mariaURL+dbConnectionQuery)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mongoDB, err := mongo.Connect(options.Client().ApplyURI(mongoURL))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer mongoDB.Disconnect(context.TODO())
|
||||
defer mariaDB.Close()
|
||||
rows, err := mariaDB.Query("select command, result, user_id, created_at from learn;")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
|
||||
i := 1
|
||||
|
||||
for rows.Next() {
|
||||
fmt.Printf("learn %d\n", i)
|
||||
err = rows.Scan(&command, &result, &userId, &createdAt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
databases.Learns.InsertOne(context.TODO(), databases.InsertLearn{
|
||||
Command: command,
|
||||
Result: result,
|
||||
UserId: userId,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
i++
|
||||
}
|
||||
}()
|
||||
|
||||
// 모든 고루틴이 끝날 떄 까지 대기
|
||||
wg.Wait()
|
||||
}
|
Loading…
Reference in a new issue