2023-10-31 22:40:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-10-31 23:19:52 +00:00
|
|
|
"github.com/ectrc/snow/aid"
|
2023-10-31 22:40:14 +00:00
|
|
|
"github.com/ectrc/snow/person"
|
|
|
|
"github.com/ectrc/snow/storage"
|
|
|
|
)
|
|
|
|
func init() {
|
2023-11-01 21:51:14 +00:00
|
|
|
aid.LoadConfig()
|
2023-10-31 22:40:14 +00:00
|
|
|
|
|
|
|
var device storage.Storage
|
2023-11-01 21:51:14 +00:00
|
|
|
switch aid.Config.Database.Type {
|
2023-10-31 22:40:14 +00:00
|
|
|
case "postgres":
|
|
|
|
postgresStorage := storage.NewPostgresStorage()
|
|
|
|
|
2023-11-02 17:50:52 +00:00
|
|
|
if aid.Config.Database.DropAllTables {
|
|
|
|
aid.Print("Dropping all tables")
|
2023-10-31 22:40:14 +00:00
|
|
|
postgresStorage.DropTables()
|
|
|
|
}
|
|
|
|
|
|
|
|
postgresStorage.Migrate(&storage.DB_Person{}, "Persons")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Loadout{}, "Loadouts")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Profile{}, "Profiles")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Item{}, "Items")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Gift{}, "Gifts")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Quest{}, "Quests")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Loot{}, "Loot")
|
|
|
|
postgresStorage.Migrate(&storage.DB_VariantChannel{}, "Variants")
|
|
|
|
postgresStorage.Migrate(&storage.DB_PAttribute{}, "Attributes")
|
|
|
|
|
|
|
|
device = postgresStorage
|
|
|
|
}
|
2023-10-31 23:19:52 +00:00
|
|
|
|
2023-10-31 22:40:14 +00:00
|
|
|
storage.Repo = storage.NewStorage(device)
|
|
|
|
storage.Cache = storage.NewPersonsCacheMutex()
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
go storage.Cache.CacheKiller()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-11-01 21:51:14 +00:00
|
|
|
aid.PrintTime("Fetching Persons", func() {
|
2023-11-02 17:50:52 +00:00
|
|
|
users := person.AllFromDatabase()
|
|
|
|
aid.Print("Found", len(users), "users")
|
|
|
|
for _, user := range users {
|
|
|
|
aid.Print(user.ID)
|
|
|
|
}
|
2023-11-01 21:51:14 +00:00
|
|
|
})
|
2023-11-01 21:33:25 +00:00
|
|
|
|
2023-11-01 01:24:42 +00:00
|
|
|
// aid.WaitForExit()
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|