Skip to content

Commit c0616e3

Browse files
committed
fix: add coalesce function to query for handling null return values per ticket 321
1 parent 0c2cd42 commit c0616e3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/src/database/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (db *DB) NewUsersInTimePeriod(days int, facilityId *uint) (int64, int64, er
281281
func (db *DB) GetTotalLogins(days int, facilityId *uint) (int64, error) {
282282
var total int64
283283
daysAgo := time.Now().AddDate(0, 0, -days)
284-
tx := db.Model(&models.LoginActivity{}).Select("SUM(total_logins)").Where("time_interval >= ?", daysAgo)
284+
tx := db.Model(&models.LoginActivity{}).Select("COALESCE(SUM(total_logins), 0)").Where("time_interval >= ?", daysAgo)
285285
if facilityId != nil {
286286
tx = tx.Where("facility_id = ?", *facilityId)
287287
}

0 commit comments

Comments
 (0)