1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

Subscription checks

This commit is contained in:
Harvey Kandola 2018-10-29 16:53:54 +00:00
parent 6e4c5194e2
commit e116d3b000
20 changed files with 211 additions and 76 deletions

View file

@ -14,6 +14,7 @@ package user
import (
"database/sql"
"fmt"
"github.com/documize/community/core/env"
"strconv"
"strings"
"time"
@ -312,17 +313,11 @@ func (s Store) ForgotUserPassword(ctx domain.RequestContext, email, token string
}
// CountActiveUsers returns the number of active users in the system.
func (s Store) CountActiveUsers() (c int) {
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE c_active=true)")
err := row.Scan(&c)
if err == sql.ErrNoRows {
return 0
}
func (s Store) CountActiveUsers() (c []env.LicenseUserAcount) {
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active=true GROUP BY c_orgid ORDER BY c_orgid")
if err != nil && err != sql.ErrNoRows {
s.Runtime.Log.Error("CountActiveUsers", err)
return 0
}
return