Skip to content

Commit

Permalink
fix: subject template group
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Nov 9, 2023
1 parent ade0229 commit 9d166ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/database/dao/subject_template_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (m *subjectTemplateGroupManager) GetMaxExpiredAtBySubjectGroup(
) (int64, error) {
var expiredAt int64
query := `SELECT
MAX(expired_at)
COALESCE(MAX(expired_at), 0)
FROM subject_template_group
WHERE subject_pk = ?
AND group_pk = ?
Expand Down
8 changes: 4 additions & 4 deletions pkg/service/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (l *groupService) BulkDeleteGroupMembers(
for _, subjectPK := range subjectPKs {
// 如果还有其它的未过期的, 不需要删除
expiredAt, err := l.subjectTemplateGroupManager.GetMaxExpiredAtBySubjectGroup(subjectPK, groupPK, 0)
if err != nil && err != ErrGroupMemberNotFound {
if err != nil {
return nil, errorWrapf(
err,
"getMaxExpiredAtBySubjectGroup subjectPK=`%d`, groupPK=`%d` fail",
Expand All @@ -523,7 +523,7 @@ func (l *groupService) BulkDeleteGroupMembers(
)
}

if err == nil && expiredAt > now {
if expiredAt > now {
continue
}

Expand Down Expand Up @@ -880,7 +880,7 @@ func (l *groupService) GetMaxExpiredAtBySubjectGroup(subjectPK, groupPK int64, e
groupPK,
excludeTemplateID,
)
if err2 != nil && !errors.Is(err2, sql.ErrNoRows) {
if err2 != nil {
err2 = errorx.Wrapf(
err2,
GroupSVC,
Expand All @@ -893,7 +893,7 @@ func (l *groupService) GetMaxExpiredAtBySubjectGroup(subjectPK, groupPK int64, e
return 0, err2
}

if errors.Is(err1, sql.ErrNoRows) && errors.Is(err2, sql.ErrNoRows) {
if errors.Is(err1, sql.ErrNoRows) && subjectTemplateGroupExpiredAt == 0 {
return 0, ErrGroupMemberNotFound
}

Expand Down

0 comments on commit 9d166ef

Please sign in to comment.