Skip to content

Commit e0a2d30

Browse files
Update prod (#415)
* imp(limiter): do not count events for already blocked workspaces * Revert "imp(limiter): do not count events for already blocked workspaces" This reverts commit 83961aa. * Imp(limiter): perfomance improvement (#414) * imp(limiter): do not count events for already blocked workspaces * imp(limiter): do not count events for blocked workspaces * imp(): remove redundant condition --------- Co-authored-by: e11sy <130844513+e11sy@users.noreply.github.com>
1 parent 4fc742a commit e0a2d30

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

workers/limiter/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ export default class LimiterWorker extends Worker {
182182
const updatedWorkspaces: WorkspaceWithTariffPlan[] = [];
183183

184184
await Promise.all(workspaces.map(async (workspace) => {
185+
/**
186+
* If workspace is already blocked - do nothing
187+
*/
188+
if (workspace.isBlocked) {
189+
return;
190+
}
191+
185192
const workspaceProjects = await this.dbHelper.getProjects(workspace._id.toString());
186193

187194
const { shouldBeBlockedByQuota, updatedWorkspace, projectsToUpdate } = await this.prepareWorkspaceUsageUpdate(workspace, workspaceProjects);
@@ -198,7 +205,7 @@ export default class LimiterWorker extends Worker {
198205
/**
199206
* If workspace is not blocked yet and it should be blocked by quota - then block it
200207
*/
201-
if (!workspace.isBlocked && shouldBeBlockedByQuota) {
208+
if (shouldBeBlockedByQuota) {
202209
const projectIds = projectsToUpdate.map(project => project._id.toString());
203210

204211
this.redis.appendBannedProjects(projectIds);

0 commit comments

Comments
 (0)