Skip to content

Commit e55b783

Browse files
committed
review comment
1 parent c2831be commit e55b783

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/appStore/installedApp/repository/InstalledAppRepository.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,10 @@ func (impl *InstalledAppRepositoryImpl) GetAllArgoAppsByDeploymentAppNames(deplo
10901090

10911091
func (impl *InstalledAppRepositoryImpl) GetActiveInstalledAppCount() (int, error) {
10921092
var count int
1093-
countQuery := "SELECT COUNT(*) FROM installed_apps WHERE active = true;"
1094-
_, err := impl.dbConnection.Query(&count, countQuery)
1093+
count, err := impl.dbConnection.Model().
1094+
Table("installed_apps").
1095+
Where("active = ?", true).
1096+
Count()
10951097
if err != nil {
10961098
impl.Logger.Errorw("error in getting active installed app count", "err", err)
10971099
return 0, err

pkg/auth/user/repository/UserAuditRepository.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ func (impl UserAuditRepositoryImpl) GetLatestUser() (*UserAudit, error) {
8989
}
9090

9191
func (impl UserAuditRepositoryImpl) GetActiveUsersCountInLast30Days() (int, error) {
92-
var count int
93-
// Calculate the date 30 days ago from now
92+
// Calculated the date 30 days ago from now
9493
thirtyDaysAgo := time.Now().AddDate(0, 0, -30)
9594

96-
// Count distinct users who have been active (have updated_on) in the last 30 days
97-
_, err := impl.dbConnection.Query(&count,
98-
"SELECT COUNT(DISTINCT user_id) FROM user_audit WHERE updated_on >= ?",
99-
thirtyDaysAgo)
95+
count, err := impl.dbConnection.Model().
96+
Table("user_audit").
97+
ColumnExpr("COUNT(DISTINCT user_id)").
98+
Where("updated_on >= ?", thirtyDaysAgo).
99+
Count()
100100

101101
return count, err
102102
}

0 commit comments

Comments
 (0)