From befc288efe44783aae623eb2883166e2e8e3850e Mon Sep 17 00:00:00 2001 From: bean Date: Wed, 22 May 2024 00:55:44 +0700 Subject: [PATCH] fix: use discord username as optional in querying discord accounts (#705) Co-authored-by: Bean Vo --- pkg/store/discordaccount/discord_account.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/store/discordaccount/discord_account.go b/pkg/store/discordaccount/discord_account.go index 6045cd30d..f6c57613f 100644 --- a/pkg/store/discordaccount/discord_account.go +++ b/pkg/store/discordaccount/discord_account.go @@ -56,9 +56,9 @@ func (r *store) UpdateSelectedFieldsByID(db *gorm.DB, id string, updateModel mod return &discordAccount, db.Model(&discordAccount).Where("id = ?", id).Select(updatedFields).Updates(updateModel).Error } -// ListByMemoUsername gets a list of discord accounts by memo usernames +// ListByMemoUsername gets a list of discord accounts by memo usernames, if memo username is not found, it will try to find by discord username func (r *store) ListByMemoUsername(db *gorm.DB, usernames []string) ([]model.DiscordAccount, error) { var cms []model.DiscordAccount - err := db.Where("memo_username IN (?)", usernames).Find(&cms).Error + err := db.Where("memo_username IN (?) OR discord_username IN (?)", usernames, usernames).Find(&cms).Error return cms, err }