feat: Include totalUsers in usage metrics during license renewal (no-changelog) (#8598)

This commit is contained in:
Cornelius Suermann 2024-02-09 14:15:05 +01:00 committed by GitHub
parent 79b09fdf84
commit cd151f1ba9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

View file

@ -29,6 +29,7 @@ export class UsageMetricsRepository extends Repository<UsageMetrics> {
async getLicenseRenewalMetrics() {
type Row = {
enabled_user_count: string | number;
total_user_count: string | number;
active_workflow_count: string | number;
total_workflow_count: string | number;
total_credentials_count: string | number;
@ -44,6 +45,7 @@ export class UsageMetricsRepository extends Repository<UsageMetrics> {
const [
{
enabled_user_count: enabledUsers,
total_user_count: totalUsers,
active_workflow_count: activeWorkflows,
total_workflow_count: totalWorkflows,
total_credentials_count: totalCredentials,
@ -53,6 +55,7 @@ export class UsageMetricsRepository extends Repository<UsageMetrics> {
] = (await this.query(`
SELECT
(SELECT COUNT(*) FROM ${userTable} WHERE disabled = false) AS enabled_user_count,
(SELECT COUNT(*) FROM ${userTable}) AS total_user_count,
(SELECT COUNT(*) FROM ${workflowTable} WHERE active = true) AS active_workflow_count,
(SELECT COUNT(*) FROM ${workflowTable}) AS total_workflow_count,
(SELECT COUNT(*) FROM ${credentialTable}) AS total_credentials_count,
@ -65,6 +68,7 @@ export class UsageMetricsRepository extends Repository<UsageMetrics> {
return {
enabledUsers: toNumber(enabledUsers),
totalUsers: toNumber(totalUsers),
activeWorkflows: toNumber(activeWorkflows),
totalWorkflows: toNumber(totalWorkflows),
totalCredentials: toNumber(totalCredentials),

View file

@ -10,6 +10,7 @@ export class UsageMetricsService {
activeWorkflows,
totalWorkflows,
enabledUsers,
totalUsers,
totalCredentials,
productionExecutions,
manualExecutions,
@ -19,6 +20,7 @@ export class UsageMetricsService {
{ name: 'activeWorkflows', value: activeWorkflows },
{ name: 'totalWorkflows', value: totalWorkflows },
{ name: 'enabledUsers', value: enabledUsers },
{ name: 'totalUsers', value: totalUsers },
{ name: 'totalCredentials', value: totalCredentials },
{ name: 'productionExecutions', value: productionExecutions },
{ name: 'manualExecutions', value: manualExecutions },

View file

@ -64,6 +64,7 @@ describe('UsageMetricsRepository', () => {
expect(metrics).toStrictEqual({
enabledUsers: 4,
totalUsers: 5,
totalCredentials: 2,
totalWorkflows: 5,
activeWorkflows: 3,
@ -79,6 +80,7 @@ describe('UsageMetricsRepository', () => {
expect(metrics).toStrictEqual({
enabledUsers: 1,
totalUsers: 1,
totalCredentials: 0,
totalWorkflows: 3,
activeWorkflows: 3,