Skip to content

Feat/parmanent scraping task#224

Open
ToYama170402 wants to merge 14 commits into
mainfrom
feat/parmanent-scraping-task
Open

Feat/parmanent scraping task#224
ToYama170402 wants to merge 14 commits into
mainfrom
feat/parmanent-scraping-task

Conversation

@ToYama170402
Copy link
Copy Markdown
Owner

変更内容

syllabus-scrapeのスケジューラに登録されたタスクを永続化した。

変更の種類

  • バグ修正(Bug fix)
  • 新機能(New feature)
  • 破壊的変更(Breaking change)
  • ドキュメント更新(Documentation update)
  • リファクタリング(Refactoring)
  • パフォーマンス改善(Performance improvement)
  • テスト追加・修正(Test update)
  • その他(Other)

関連Issue

Closes #

変更の詳細

BullMQを使ってタスクスケジューラを実装。
TimeRangeSchedulerのインターフェイスを変更したためTimeRangeSchedulerの実装やmain.tsの実装も変更した。

テスト

  • 既存のテストが通ることを確認
  • 新しいテストを追加
  • 手動でテスト実施

テスト内容

チェックリスト

  • コードが正常に動作することを確認した
  • 適切なコメントを追加した(必要に応じて)
  • ドキュメントを更新した(必要に応じて)
  • 新しい警告が発生していないことを確認した
  • 依存関係の追加や更新がある場合、その理由を説明した

スクリーンショット

その他

@ToYama170402 ToYama170402 self-assigned this May 11, 2026
Copilot AI review requested due to automatic review settings May 11, 2026 13:07
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rishu-app Ready Ready Preview, Comment May 13, 2026 1:41am
rishu-app-storybook Ready Ready Preview, Comment May 13, 2026 1:41am

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the scraping scheduler from a custom time-range implementation to a distributed queue system using BullMQ and Redis. It includes updates to the Docker configuration, the introduction of a new BullMQScheduler, and a refactor of the scraping logic into worker-based tasks. Feedback focuses on improving robustness and maintainability, specifically by handling potential NaN values in port parsing, correcting the implementation of worker concurrency, simplifying complex TypeScript type inferences, and replacing hardcoded values with dynamic logic or constants.

Comment thread syllabus-scrape/src/main.ts Outdated
Comment thread syllabus-scrape/src/scheduler/bullmqScheduler.ts
Comment thread syllabus-scrape/src/main.ts Outdated
Comment thread syllabus-scrape/src/main.ts
Comment thread syllabus-scrape/src/main.ts Outdated
);
}
},
6
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.

medium

並行処理数6がマジックナンバーになっています。可読性とメンテナンス性を向上させるために、ファイルの先頭で定数として定義することをお勧めします(例:const WORKER_CONCURRENCY = 6;)。これは241行目の他のワーカーにも適用されます。

Suggested change
6
WORKER_CONCURRENCY

Comment thread syllabus-scrape/src/main.ts Outdated
logger.log(`Faculty: ${department}`, "error");
}
},
6
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.

medium

並行処理数6がマジックナンバーになっています。可読性とメンテナンス性を向上させるために、ファイルの先頭で定数として定義することをお勧めします(例:const WORKER_CONCURRENCY = 6;)。

Suggested change
6
WORKER_CONCURRENCY

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 migrates syllabus-scrape task scheduling from an in-memory time-range loop to a BullMQ (Redis-backed) queue so scheduled scraping jobs can persist across process restarts. It also changes the Scheduler interface to support named workers and typed task payloads (breaking change).

Changes:

  • Introduces BullMQScheduler (BullMQ + Redis) and wires it into src/main.ts.
  • Reworks Scheduler/TimeRangeScheduler to use { type, payload } tasks plus worker registration.
  • Adds Redis service + env wiring in docker-compose.yml, and adds bullmq dependency.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
syllabus-scrape/src/scheduler/timeRangeScheduler.ts Updates in-memory scheduler to dispatch TaskPayload via registered workers
syllabus-scrape/src/scheduler/core.ts Breaking interface change: addWorker + TaskPayload
syllabus-scrape/src/scheduler/bullmqScheduler.ts New BullMQ-backed scheduler implementation
syllabus-scrape/src/main.ts Switches scraping orchestration to BullMQScheduler workers/queues
syllabus-scrape/package.json Adds bullmq dependency
syllabus-scrape/pnpm-lock.yaml Locks BullMQ + transitive deps
docker-compose.yml Adds Redis service/volume and Redis env vars for syllabus-scrape
Files not reviewed (1)
  • syllabus-scrape/pnpm-lock.yaml: Language not supported

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

Comment thread syllabus-scrape/src/main.ts Outdated
Comment thread syllabus-scrape/src/main.ts
Comment thread syllabus-scrape/src/scheduler/bullmqScheduler.ts
Comment thread syllabus-scrape/src/scheduler/bullmqScheduler.ts
Comment thread syllabus-scrape/src/scheduler/bullmqScheduler.ts Outdated
Comment on lines +10 to 13
): void;
addTask(task: TaskPayload): void;
start(): void;
stop(): void;
Comment thread syllabus-scrape/src/main.ts
Comment thread docker-compose.yml
Comment on lines +4 to +12
export class BullMQScheduler implements Scheduler {
private workers: Record<string, Worker> = {};
private queues: Record<string, Queue> = {};
private redisConfig: ConnectionOptions;

constructor(connectionOpts: ConnectionOptions) {
this.redisConfig = connectionOpts;
}

Comment thread syllabus-scrape/src/main.ts Outdated
Comment on lines +170 to +179
async (taskPayload) => {
const { syllabusSearchResult } = taskPayload as {
syllabusSearchResult: ReturnType<
typeof scrapeSyllabusSearchResult
> extends Promise<infer U>
? U extends (infer V)[]
? V
: never
: never;
};
より安全のため

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
読みにくいため
型アサーションを避けるため
予期せぬ動作を防ぐため
平行処理数と勘違いされたため
正常に処理を止めるため
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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