Skip to content

Replace manual batch loops with declarative MapTask from @workglow/* … - #60

Merged
sroussey merged 1 commit into
mainfrom
update-map
Mar 2, 2026
Merged

Replace manual batch loops with declarative MapTask from @workglow/* …#60
sroussey merged 1 commit into
mainfrom
update-map

Conversation

@sroussey

Copy link
Copy Markdown
Contributor

…v0.0.103

Leverage Workflow.map()/endMap() to replace hand-rolled TaskGraph loops, batched Promise.all patterns, and sequential pipe chains across 5 task files. This reduces boilerplate, fixes an unintended sequential execution bug in FetchAndStoreFormsTask, and standardizes concurrency control.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades several SEC ingestion/update tasks to use Workflow.map()/endMap() (from @workglow/task-graph v0.0.103) instead of hand-rolled batching/loop orchestration, aiming to reduce boilerplate and standardize concurrency behavior.

Changes:

  • Replaced manual loop/batch patterns with Workflow.map() in submissions, facts, forms, and quarterly index range tasks.
  • Introduced per-task concurrency limits via map({ concurrencyLimit: ... }) to replace prior batch sizes / parallel Promise.all patterns.
  • Adjusted quarterly index range aggregation logic to work with mapped results rather than TaskGraph results.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/task/submissions/UpdateAllSubmissionsTask.ts Refactors update + initial processing loops to Workflow.map() with concurrency limits and a shared mapped handler.
src/task/index/FetchQuarterlyIndexRangeTask.ts Replaces TaskGraph fan-out with Workflow.map() over computed quarter start dates and merges mapped outputs.
src/task/forms/UpdateAllFormsTask.ts Replaces batched Promise.all processing of missing forms with Workflow.map({ concurrencyLimit: 10 }).
src/task/forms/FetchAndStoreFormsTask.ts Fixes prior sequential workflow piping by mapping filings into ProcessAccessionDocFormTask with concurrency.
src/task/facts/UpdateAllCompanyFactsTask.ts Refactors update + initial processing loops to Workflow.map() and adds a mapped fetch/store handler with concurrency limits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 100 to 107
@@ -132,4 +106,5 @@ async function runWorkflow(wf: IWorkflow<any, any>, input: { cik: string; date:
}
);

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processed_facts is created with a success bool not null column (see src/util/db.ts), but this insert only provides cik and last_processed. On a fresh DB this will violate the NOT NULL constraint and the failure-handling path will throw, masking the original error. Include a $success value (likely false) in the insert, or update the table schema to match what the code writes.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to 52
const needsUpating = query_all<{
cik: string;
last_update: string;
last_processed: string;
}>(`
SELECT cik_last_update.cik, cik_last_update.last_update, processed_submissions.last_processed FROM cik_last_update
JOIN processed_submissions
ON cik_last_update.cik = processed_submissions.cik
WHERE cik_last_update.last_update > processed_submissions.last_processed
WHERE cik_last_update.last_update > processed_submissions.last_processed
ORDER BY cik_last_update.last_update DESC`);
const needsUpatingCount = needsUpating?.length ?? 0;

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name needsUpating looks like a typo (missing 'd' in 'Updating'). Since it’s used throughout this method, consider renaming it (and the associated count variables) to needsUpdating for clarity and to avoid propagating the misspelling.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to 52
const needsUpating = query_all<{
cik: string;
last_update: string;
last_processed: string;
}>(`
SELECT cik_last_update.cik, cik_last_update.last_update, processed_facts.last_processed FROM cik_last_update
JOIN processed_facts
ON cik_last_update.cik = processed_facts.cik
WHERE cik_last_update.last_update > processed_facts.last_processed
WHERE cik_last_update.last_update > processed_facts.last_processed
ORDER BY cik_last_update.last_update DESC`);
const needsUpatingCount = needsUpating?.length ?? 0;

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name needsUpating looks like a typo (missing 'd' in 'Updating'). Consider renaming it (and the derived needsUpatingCount) to needsUpdating/needsUpdatingCount to improve readability.

Copilot uses AI. Check for mistakes.
…v0.0.103

Leverage Workflow.map()/endMap() to replace hand-rolled TaskGraph loops,
batched Promise.all patterns, and sequential pipe chains across 5 task
files. This reduces boilerplate, fixes an unintended sequential execution
bug in FetchAndStoreFormsTask, and standardizes concurrency control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sroussey
sroussey merged commit 622fc4a into main Mar 2, 2026
1 of 2 checks passed
@sroussey
sroussey deleted the update-map branch July 17, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants