fix(automations): fix ExecutionStep status mismatch, branch operator precedence, and 10k row cap in getAutomationAnalytics
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, typescript
Direzione di ricerca
Start with getAutomationAnalytics in apps/api/src/automations/automations.service.ts and compare its status checks with the writes in apps/workers/src/workers/comment-worker.ts and message-worker.ts. Inspect the Prisma models and existing aggregation patterns before replacing the capped queries with database aggregations. Done means both success statuses count, branch values resolve correctly, and analytics totals are no longer truncated by the row caps.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem Description
In apps/api/src/automations/automations.service.ts (getAutomationAnalytics, lines 950-1014):
-
Step
successCountis always0('SUCCESS'vs'COMPLETED'):- Workers (
apps/workers/src/workers/comment-worker.tsline 157 andapps/workers/src/workers/message-worker.tsline 294) writeExecutionStep.status = 'SUCCESS'. getAutomationAnalytics(line 1006) checksif (step.status === 'COMPLETED'), so successful DM and comment-reply steps are never counted towardsuccessCount.
- Workers (
-
Operator precedence bug turns
out.branchinto'undefined':- Line 1014 writes:
const branchKey = out.branch || out.conditionResult !== undefined ? String(out.conditionResult) : null; - Because
||binds tighter than!==, JavaScript evaluates(out.branch || out.conditionResult) !== undefined. Wheneverout.branchis truthy andout.conditionResultisundefined,branchKeyevaluates to the literal string'undefined'instead ofout.branch.
- Line 1014 writes:
-
Independent in-memory row caps skew totals at scale:
getAutomationAnalyticsindependently capsexecutions(take: 2000) andexecutionSteps(take: 10000) and aggregates in memory, causingtotalTriggersand per-node step metrics to silently truncate and drift for high-volume automations.
Expected Behavior
getAutomationAnalyticscounts both'SUCCESS'and'COMPLETED'step statuses as successful.branchKeyresolvesout.branchwhen present, falling back toString(out.conditionResult)only whenout.conditionResult !== undefined.- Total trigger counts, execution status breakdowns, and per-node step counts are computed via database aggregations (
count/groupBy) rather than loading up to 10,000 rows into Node memory.
Where to Look
apps/api/src/automations/automations.service.ts(getAutomationAnalytics, lines 950-1014)apps/workers/src/workers/comment-worker.ts(line 157)apps/workers/src/workers/message-worker.ts(line 294)
Solution / Implementation Guide
- Fix status check:
- Count
step.status === 'SUCCESS' || step.status === 'COMPLETED'(or standardize workers and analytics on the same status while keeping backward compatibility for existing'SUCCESS'rows).
- Count
- Fix operator precedence on line 1014:
- Update to:
const branchKey = out.branch ? String(out.branch) : (out.conditionResult !== undefined ? String(out.conditionResult) : null);
- Update to:
- Use DB aggregations instead of
take: 2000/take: 10000in-memory loops:- Use
prisma.automationExecution.groupBy({ by: ['status'], ... })andprisma.executionStep.groupBy({ by: ['nodeId', 'status'], ... })for accurate totals, and only queryoutputbranch counts via targeted SQL aggregation.
- Use
- Lingua principale
- TypeScript
- Stelle
- 2
- Fork
- 1
- Merge medio
- 6m
- PR unite (30g)
- 27
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sumamakhan761/tryinstance
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#65 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sumamakhan761/tryinstance#64 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
sumamakhan761/tryinstance#63 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#62 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#60 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sumamakhan761/tryinstance
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
makecindy/cindy#15342 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
kwitsch/claude-code-plugin-tooling#219 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
no-repo-link tool-submission
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100