mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
fix(core): Reduce payload of license renewal calls (no-changelog) (#12236)
This commit is contained in:
committed by
GitHub
parent
2c9b690010
commit
de49182652
@@ -44,10 +44,12 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveIds() {
|
async getActiveIds({ maxResults }: { maxResults?: number } = {}) {
|
||||||
const activeWorkflows = await this.find({
|
const activeWorkflows = await this.find({
|
||||||
select: ['id'],
|
select: ['id'],
|
||||||
where: { active: true },
|
where: { active: true },
|
||||||
|
// 'take' and 'order' are only needed when maxResults is provided:
|
||||||
|
...(maxResults ? { take: maxResults, order: { createdAt: 'ASC' } } : {}),
|
||||||
});
|
});
|
||||||
return activeWorkflows.map((workflow) => workflow.id);
|
return activeWorkflows.map((workflow) => workflow.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ export class LicenseMetricsService {
|
|||||||
|
|
||||||
async collectPassthroughData() {
|
async collectPassthroughData() {
|
||||||
return {
|
return {
|
||||||
activeWorkflowIds: await this.workflowRepository.getActiveIds(),
|
// Get only the first 1000 active workflow IDs to avoid sending too much data to License Server
|
||||||
|
// Passthrough data is forwarded to Telemetry for further analysis, such as quota excesses
|
||||||
|
activeWorkflowIds: await this.workflowRepository.getActiveIds({ maxResults: 1000 }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ describe('WorkflowRepository', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getActiveIds', () => {
|
describe('getActiveIds', () => {
|
||||||
it('should return active workflow IDs', async () => {
|
it('should return all active workflow IDs when invoked without maxResults', async () => {
|
||||||
//
|
//
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
//
|
//
|
||||||
@@ -92,6 +92,28 @@ describe('WorkflowRepository', () => {
|
|||||||
// ASSERT
|
// ASSERT
|
||||||
//
|
//
|
||||||
expect(activeIds).toEqual([workflows[0].id]);
|
expect(activeIds).toEqual([workflows[0].id]);
|
||||||
|
expect(activeIds).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a capped number of active workflow IDs when invoked with maxResults', async () => {
|
||||||
|
//
|
||||||
|
// ARRANGE
|
||||||
|
//
|
||||||
|
await Promise.all([
|
||||||
|
createWorkflow({ active: true }),
|
||||||
|
createWorkflow({ active: false }),
|
||||||
|
createWorkflow({ active: true }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
//
|
||||||
|
// ACT
|
||||||
|
//
|
||||||
|
const activeIds = await Container.get(WorkflowRepository).getActiveIds({ maxResults: 1 });
|
||||||
|
|
||||||
|
//
|
||||||
|
// ASSERT
|
||||||
|
//
|
||||||
|
expect(activeIds).toHaveLength(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user