🚑 Remove recursive db loading and fix a small bug ith the broadcast command

This commit is contained in:
Alphyron 2021-03-14 12:14:05 +01:00
parent 474744f928
commit fdb6eccb40
3 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ func (i infoCommand) ExecuteCommand(bot *tgbotapi.BotAPI, update *tgbotapi.Updat
"General Information to this Bot\n" + "General Information to this Bot\n" +
"===============================\n" + "===============================\n" +
"Developer: @Alphyron\n" + "Developer: @Alphyron\n" +
"Version: 2.2.2\n" + "Version: 2.2.4\n" +
"Git: [Gitea Repository](https://git.dragon-labs.de/alphyron/group_assistant)\n" + "Git: [Gitea Repository](https://git.dragon-labs.de/alphyron/group_assistant)\n" +
"===============================" "==============================="

View File

@ -94,7 +94,7 @@ func (g groupHelperRepository) GetGroupByID(id int64) (*models.Group, error) {
defaultGroup.FillDefaultValues() defaultGroup.FillDefaultValues()
defaultGroup.GroupID = id defaultGroup.GroupID = id
err := g.Conn.Set("gorm:auto_preload", true).Where("group_id = ?", id).First(&group) err := g.Conn.Preload("ControlledGroups").Where("group_id = ?", id).First(&group)
if err.RecordNotFound() { if err.RecordNotFound() {
return g.CreateGroup(defaultGroup) return g.CreateGroup(defaultGroup)
@ -214,7 +214,7 @@ func (g groupHelperRepository) GetGroupByDBID(id uint64) (*models.Group, error)
defaultGroup.FillDefaultValues() defaultGroup.FillDefaultValues()
defaultGroup.ID = id defaultGroup.ID = id
err := g.Conn.Set("gorm:auto_preload", true).Where("id = ?", id).First(&group) err := g.Conn.Preload("ControlledGroups").Where("id = ?", id).First(&group)
if err.RecordNotFound() { if err.RecordNotFound() {
return g.CreateGroup(defaultGroup) return g.CreateGroup(defaultGroup)