bump: db version & bulk import
Signed-off-by: Ben Hall <ben@benh.codes>
This commit is contained in:
parent
276d1f47ca
commit
3609ff0a44
@ -657,13 +657,12 @@ func ImportHandler(ctx *gin.Context) {
|
||||
ticketsExtrasGroup, _ := errgroup.WithContext(queryCtx)
|
||||
|
||||
ticketsExtrasGroup.Go(func() (err error) {
|
||||
// Import ticket additional members
|
||||
newMembersMap := make(map[int][]uint64)
|
||||
for ticketId, members := range data.TicketAdditionalMembers {
|
||||
for _, member := range members {
|
||||
err = dbclient.Client.TicketMembers.Add(queryCtx, guildId, ticketIdMap[ticketId], member)
|
||||
return
|
||||
}
|
||||
newMembersMap[ticketIdMap[ticketId]] = members
|
||||
}
|
||||
// Remap ticket ids in data.TicketAdditionalMembers
|
||||
err = dbclient.Client2.TicketMembers.ImportBulk(queryCtx, guildId, newMembersMap)
|
||||
return
|
||||
})
|
||||
|
||||
@ -690,27 +689,35 @@ func ImportHandler(ctx *gin.Context) {
|
||||
return
|
||||
})
|
||||
|
||||
// Import ticket claims
|
||||
ticketsExtrasGroup.Go(func() (err error) {
|
||||
for _, claim := range data.TicketClaims {
|
||||
err = dbclient.Client.TicketClaims.Set(queryCtx, guildId, ticketIdMap[claim.TicketId], claim.Data)
|
||||
newClaimsMap := make(map[int]uint64)
|
||||
for ticketId, user := range data.TicketClaims {
|
||||
newClaimsMap[ticketIdMap[ticketId]] = user.Data
|
||||
}
|
||||
|
||||
err = dbclient.Client2.TicketClaims.ImportBulk(queryCtx, guildId, newClaimsMap)
|
||||
return
|
||||
})
|
||||
|
||||
// Import ticket ratings
|
||||
ticketsExtrasGroup.Go(func() (err error) {
|
||||
for _, rating := range data.ServiceRatings {
|
||||
err = dbclient.Client.ServiceRatings.Set(queryCtx, guildId, ticketIdMap[rating.TicketId], uint8(rating.Data))
|
||||
newRatingsMap := make(map[int]uint8)
|
||||
for ticketId, rating := range data.ServiceRatings {
|
||||
newRatingsMap[ticketIdMap[ticketId]] = uint8(rating.Data)
|
||||
}
|
||||
|
||||
err = dbclient.Client2.ServiceRatings.ImportBulk(queryCtx, guildId, newRatingsMap)
|
||||
return
|
||||
})
|
||||
|
||||
// Import participants
|
||||
ticketsExtrasGroup.Go(func() (err error) {
|
||||
newParticipantsMap := make(map[int][]uint64)
|
||||
for ticketId, participants := range data.Participants {
|
||||
err = dbclient.Client.Participants.SetBulk(queryCtx, guildId, ticketIdMap[ticketId], participants)
|
||||
newParticipantsMap[ticketIdMap[ticketId]] = participants
|
||||
}
|
||||
|
||||
err = dbclient.Client2.Participants.ImportBulk(queryCtx, guildId, newParticipantsMap)
|
||||
return
|
||||
})
|
||||
|
||||
|
11
go.mod
11
go.mod
@ -2,9 +2,12 @@ module github.com/TicketsBot/GoPanel
|
||||
|
||||
go 1.22.6
|
||||
|
||||
// replace github.com/TicketsBot-cloud/database => ../database
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1
|
||||
github.com/TicketsBot-cloud/archiverclient v0.0.0-20250206203822-d4f91573ad70
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209183433-92dad7c593f6
|
||||
github.com/TicketsBot/common v0.0.0-20241117150316-ff54c97b45c1
|
||||
github.com/TicketsBot/database v0.0.0-20250205194156-c8239ae6eb4e
|
||||
github.com/TicketsBot/logarchiver v0.0.0-20241012220745-5f3ba17a5138
|
||||
@ -24,6 +27,8 @@ require (
|
||||
github.com/jackc/pgconn v1.14.3
|
||||
github.com/jackc/pgtype v1.14.4
|
||||
github.com/jackc/pgx/v4 v4.18.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/minio/minio-go/v7 v7.0.85
|
||||
github.com/penglongli/gin-metrics v0.1.10
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.20.5
|
||||
@ -37,12 +42,6 @@ require (
|
||||
|
||||
require github.com/TicketsBot/archiverclient v0.0.0-20241012221057-16a920bfb454 // indirect
|
||||
|
||||
require (
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209171533-92f4ee4cabc7
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/minio/minio-go/v7 v7.0.85
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/ClickHouse/ch-go v0.52.1 // indirect
|
||||
github.com/ClickHouse/clickhouse-go/v2 v2.10.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -45,8 +45,8 @@ github.com/TicketsBot-cloud/archiverclient v0.0.0-20250206203822-d4f91573ad70 h1
|
||||
github.com/TicketsBot-cloud/archiverclient v0.0.0-20250206203822-d4f91573ad70/go.mod h1:BtS3JYHIuRStuUm909E7IDAwg7aAuiS5CNfIH5Y+Ayw=
|
||||
github.com/TicketsBot-cloud/common v0.0.0-20250208140430-b5da1dd487b3 h1:2rpwH5o8negd0BCqWG8xv9r0jh/fYK3P/V3WJ+yFDKs=
|
||||
github.com/TicketsBot-cloud/common v0.0.0-20250208140430-b5da1dd487b3/go.mod h1:gn88nKOiWkAgFhhTyuuo+sPFAQEVdTK+P/VXAxOBKNw=
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209171533-92f4ee4cabc7 h1:ACc/DTgjAh29v0UYAfY7pRY5/SjR9J980JSC461vAc0=
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209171533-92f4ee4cabc7/go.mod h1:LPDEn9e5wccH7rq/pUlVcL3UhyLnnwdM2dhj0tp/ljo=
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209183433-92dad7c593f6 h1:sllM5xdcCSDk5h26fjNEGCE4rT3NsJjriD82pjutJ/I=
|
||||
github.com/TicketsBot-cloud/database v0.0.0-20250209183433-92dad7c593f6/go.mod h1:LPDEn9e5wccH7rq/pUlVcL3UhyLnnwdM2dhj0tp/ljo=
|
||||
github.com/TicketsBot/analytics-client v0.0.0-20240724103359-30f5dac821e6 h1:JigBTrKv/wRkCnz0G9m/EsqmG5DU6pFWBtrXNhcvK3E=
|
||||
github.com/TicketsBot/analytics-client v0.0.0-20240724103359-30f5dac821e6/go.mod h1:9Z9qP/yovb6DUe1KlzgN2wicc+8ey6MMoxfynFbMyRg=
|
||||
github.com/TicketsBot/archiverclient v0.0.0-20241012221057-16a920bfb454 h1:u77mqvmLdljjircnvgikSWNOSyc2uSLLybPOQP8moK8=
|
||||
|
Loading…
x
Reference in New Issue
Block a user