Skip to content

Commit 6ab5a07

Browse files
committed
Use the server as the truth for omitted environments
1 parent 5f5c8d7 commit 6ab5a07

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/webapp/app/v3/services/allocateConcurrency.server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export class AllocateConcurrencyService extends BaseService {
4242
(acc, e) => Math.max(0, e.maximumConcurrencyLimit - e.planConcurrencyLimit) + acc,
4343
0
4444
);
45-
const newExtra = environments.reduce((acc, e) => e.amount + acc, 0);
45+
const requested = new Map(environments.map((e) => [e.id, e.amount]));
46+
const newExtra = result.environments.reduce((acc, env) => {
47+
const targetExtra = requested.has(env.id)
48+
? Math.max(0, requested.get(env.id)!)
49+
: Math.max(0, env.maximumConcurrencyLimit - env.planConcurrencyLimit);
50+
return acc + targetExtra;
51+
}, 0);
4652
const change = newExtra - previousExtra;
4753

4854
const totalExtra = result.extraAllocatedConcurrency + change;

0 commit comments

Comments
 (0)