MUserNotifSettingChannelDefault,
MUserWithNotificationSetting,
MVideoFullLight
-} from '@server/typings/models'
+} from '@server/types/models'
enum ScopeNames {
FOR_ME_API = 'FOR_ME_API',
@Column
pluginAuth: string
+ @AllowNull(true)
+ @Default(null)
+ @Column
+ lastLoginDate: Date
+
@CreatedAt
createdAt: Date
return this.count()
}
- static listForApi (start: number, count: number, sort: string, search?: string) {
- let where: WhereOptions
+ static listForApi (parameters: {
+ start: number
+ count: number
+ sort: string
+ search?: string
+ blocked?: boolean
+ }) {
+ const { start, count, sort, search, blocked } = parameters
+ const where: WhereOptions = {}
if (search) {
- where = {
+ Object.assign(where, {
[Op.or]: [
{
email: {
}
}
]
- }
+ })
+ }
+
+ if (blocked !== undefined) {
+ Object.assign(where, {
+ blocked: blocked
+ })
}
const query: FindOptions = {
}
static async getStats () {
+ function getActiveUsers (days: number) {
+ const query = {
+ where: {
+ [Op.and]: [
+ literal(`"lastLoginDate" > NOW() - INTERVAL '${days}d'`)
+ ]
+ }
+ }
+
+ return UserModel.count(query)
+ }
+
const totalUsers = await UserModel.count()
+ const totalDailyActiveUsers = await getActiveUsers(1)
+ const totalWeeklyActiveUsers = await getActiveUsers(7)
+ const totalMonthlyActiveUsers = await getActiveUsers(30)
return {
- totalUsers
+ totalUsers,
+ totalDailyActiveUsers,
+ totalWeeklyActiveUsers,
+ totalMonthlyActiveUsers
}
}
createdAt: this.createdAt,
- pluginAuth: this.pluginAuth
+ pluginAuth: this.pluginAuth,
+
+ lastLoginDate: this.lastLoginDate
}
if (parameters.withAdminFlags) {