From d9efbf30ca268029283330fd88ec65723b8535a2 Mon Sep 17 00:00:00 2001
From: techknowlogick <hello@techknowlogick.com>
Date: Tue, 8 Oct 2024 12:29:47 -0400
Subject: [PATCH] close session immediately

---
 models/user/badge.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/models/user/badge.go b/models/user/badge.go
index 76c5772638f..1497981d991 100644
--- a/models/user/badge.go
+++ b/models/user/badge.go
@@ -185,11 +185,11 @@ func (opts *SearchBadgeOptions) ToJoins() []db.JoinFunc {
 
 func SearchBadges(ctx context.Context, opts *SearchBadgeOptions) (badges []*Badge, _ int64, _ error) {
 	sessCount := opts.toSearchQueryBase(ctx)
-	defer sessCount.Close()
 	count, err := sessCount.Count(new(Badge))
 	if err != nil {
 		return nil, 0, fmt.Errorf("count: %w", err)
 	}
+	sessCount.Close()
 
 	if len(opts.OrderBy) == 0 {
 		opts.OrderBy = db.SearchOrderByID