add setup insert methods

This commit is contained in:
lbenedar
2026-04-16 18:30:00 +03:00
parent 69d3d38ab7
commit 1b7c7e9ae3
23 changed files with 818 additions and 144 deletions

View File

@@ -43,49 +43,53 @@ type System struct {
// SystemFlags SystemFlags `json:"flags"`
}
func (s *System) ToDB(dest *db.System) bool {
func (s *System) ToDB(dest **db.System) bool {
if dest == nil {
return false
}
dest.ID = s.ID
dest.Title = s.Title
dest.Description = s.Description
dest.URL = s.URL
dest.License = s.License
dest.Bugs = s.Bugs
dest.Changelog = s.Changelog
dest.Version = s.Version
dest.Socket = s.Socket
dest.Manifest = s.Manifest
dest.Download = s.Download
dest.Protected = s.Protected
dest.Exclusive = s.Exclusive
dest.PersistentStorage = s.PersistentStorage
dest.Background = s.Background
dest.PrimaryTokenAttribute = s.PrimaryTokenAttribute
dest.Availability = s.Availability
dest.Locked = s.Locked
dest.Owned = s.Owned
dest.HasStorage = s.HasStorage
system := &db.System{
ID: s.ID,
Title: s.Title,
Description: s.Description,
URL: s.URL,
License: s.License,
Bugs: s.Bugs,
Changelog: s.Changelog,
Version: s.Version,
Socket: s.Socket,
Manifest: s.Manifest,
Download: s.Download,
Protected: s.Protected,
Exclusive: s.Exclusive,
PersistentStorage: s.PersistentStorage,
Background: s.Background,
PrimaryTokenAttribute: s.PrimaryTokenAttribute,
Availability: s.Availability,
Locked: s.Locked,
Owned: s.Owned,
HasStorage: s.HasStorage,
}
copy(dest.Scripts, s.Scripts)
copy(dest.Esmodules, s.Esmodules)
copy(dest.Tags, s.Tags)
copy(system.Scripts, s.Scripts)
copy(system.Esmodules, s.Esmodules)
copy(system.Tags, s.Tags)
s.Compatibility.ToDB(&dest.Compatibility)
s.Relationships.ToDB(&dest.Relationships)
s.DocumentTypes.ToDB(&dest.DocumentTypes)
s.Grid.ToDB(&dest.Grid)
s.Compatibility.ToDB(&system.Compatibility)
s.Relationships.ToDB(&system.Relationships)
s.DocumentTypes.ToDB(&system.DocumentTypes)
s.Grid.ToDB(&system.Grid)
wg := sync.WaitGroup{}
go CopySliceToDBParallel(&wg, &dest.Authors, s.Authors)
go CopySliceToDBParallel(&wg, &dest.Media, s.Media)
go CopySliceToDBParallel(&wg, &dest.Styles, s.Styles)
go CopySliceToDBParallel(&wg, &dest.Languages, s.Languages)
go CopySliceToDBParallel(&wg, &dest.Packs, s.Packs)
go CopySliceToDBParallel(&wg, &dest.PackFolders, s.PackFolders)
go CopySliceToDBParallel(&wg, &system.Authors, s.Authors)
go CopySliceToDBParallel(&wg, &system.Media, s.Media)
go CopySliceToDBParallel(&wg, &system.Styles, s.Styles)
go CopySliceToDBParallel(&wg, &system.Languages, s.Languages)
go CopySliceToDBParallel(&wg, &system.Packs, s.Packs)
go CopySliceToDBParallel(&wg, &system.PackFolders, s.PackFolders)
wg.Wait()
*dest = system
return true
}