fix(automations): fix ExecutionStep status mismatch, branch operator precedence, and 10k row cap in getAutomationAnalytics
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- postgresql, typescript
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 6m
- Merged PRs (30d)
- 27
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sumamakhan761/tryinstance
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#65 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
sumamakhan761/tryinstance#64 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
sumamakhan761/tryinstance#63 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#62 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#60 ·
Maintainers usually reply within 1 day
All issues in sumamakhan761/tryinstance
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
makecindy/cindy#15342 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
no-repo-link tool-submission
Difficulty 1/5 Under an hour Newbie friendliness 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100