finish setup data insertion, add world insertion

This commit is contained in:
lbenedar
2026-04-22 18:18:43 +03:00
parent 21abe68858
commit f46ff8333e
66 changed files with 2257 additions and 676 deletions

View File

@@ -1,11 +1,16 @@
package json
import (
"errors"
"sync"
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
)
var (
ErrorSetupMoreThanOne = errors.New("More than one setup data")
)
func OwnershipToDB(dest *[]db.OwnershipString, src map[string]int) {
*dest = make([]db.OwnershipString, len(src))
@@ -33,8 +38,8 @@ func PackageWarningsToDB(dest *[]*db.PackageWarning, src map[string]PackageWarni
i := 0
for k, v := range src {
(*dest)[i].Key = k
v.ToDB((*dest)[i].Value)
(*dest)[i] = &db.PackageWarning{Key: k}
v.ToDB(&(*dest)[i].Value)
i++
}
}
@@ -57,7 +62,7 @@ func CopySliceToDB[destType any, srcType CastableToDB[destType]](dest *[]destTyp
}
func CopySliceToDBParallel[destType any, srcType CastableToDB[destType]](wg *sync.WaitGroup, dest *[]destType, src []srcType) {
wg.Add(1)
CopySliceToDB(dest, src)
wg.Done()
wg.Go(func() {
CopySliceToDB(dest, src)
})
}