update some things

This commit is contained in:
eccentric 2023-12-11 00:06:41 +00:00
parent 0c9b8cb6a0
commit fd7a843576
5 changed files with 23 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package aid
import (
"math/rand"
"os"
"os/signal"
"syscall"
@ -24,3 +25,13 @@ func JSONParse(input string) interface{} {
json.Unmarshal([]byte(input), &output)
return output
}
func RandomString(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
s := make([]rune, n)
for i := range s {
s[i] = letters[rand.Intn(len(letters))]
}
return string(s)
}

View File

@ -41,7 +41,11 @@ func init() {
fortnite.GenerateRandomStorefront()
if aid.Config.Database.DropAllTables {
fortnite.NewFortnitePerson("ac", "1")
username := aid.RandomString(6)
password := aid.RandomString(10)
fortnite.NewFortnitePerson(username, password)
aid.Print("Admin Credentials: username", username, "password", password)
}
fortnite.GeneratePlaylistImages()

View File

@ -15,6 +15,7 @@ type Person struct {
Profile0Profile *Profile
CollectionsProfile *Profile
CreativeProfile *Profile
DiscordID string
Discord *storage.DB_DiscordPerson
}
@ -142,10 +143,10 @@ func findHelper(databasePerson *storage.DB_Person) *Person {
CollectionsProfile: collectionsProfile,
CreativeProfile: creativeProfile,
Discord: &databasePerson.Discord,
DiscordID: databasePerson.DiscordID,
}
cache.SavePerson(person)
return person
}
@ -201,7 +202,9 @@ func (p *Person) ToDatabase() *storage.DB_Person {
ID: p.ID,
DisplayName: p.DisplayName,
Profiles: []storage.DB_Profile{},
Stats: []storage.DB_SeasonStat{},
AccessKey: p.AccessKey,
DiscordID: p.DiscordID,
}
if p.Discord != nil {
@ -285,5 +288,6 @@ func (p *Person) Snapshot() *PersonSnapshot {
CollectionsProfile: *p.CollectionsProfile.Snapshot(),
CreativeProfile: *p.CreativeProfile.Snapshot(),
Discord: *p.Discord,
DiscordID: p.DiscordID,
}
}

View File

@ -12,6 +12,7 @@ type PersonSnapshot struct {
CollectionsProfile ProfileSnapshot
CreativeProfile ProfileSnapshot
Discord storage.DB_DiscordPerson
DiscordID string
}
type ProfileSnapshot struct {

View File

@ -12,6 +12,7 @@ type DB_Person struct {
AccessKey string
Profiles []DB_Profile `gorm:"foreignkey:PersonID"`
Stats []DB_SeasonStat `gorm:"foreignkey:PersonID"`
DiscordID string
Discord DB_DiscordPerson `gorm:"foreignkey:PersonID"`
}