feat: add cron task to update gitlab repo data#1772
Merged
frank-zsy merged 2 commits intoX-lab2017:masterfrom Feb 4, 2026
Merged
feat: add cron task to update gitlab repo data#1772frank-zsy merged 2 commits intoX-lab2017:masterfrom
frank-zsy merged 2 commits intoX-lab2017:masterfrom
Conversation
Signed-off-by: frank-zsy <syzhao1988@126.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive system for synchronizing GitLab repository data (issues and merge requests) using the GitLab GraphQL API. The implementation includes scheduled tasks for fetching detailed event data, new database schema columns for tracking synchronization state, and utilities for GraphQL client management and data transformation.
Changes:
- Added GitLab GraphQL API integration with a new
graphqlApiUrlconfiguration option - Implemented scheduled tasks to fetch and store GitLab issues and merge requests with comments and reviewers
- Enhanced the gitlab_repo_list table schema with synchronization metadata fields (issue_updated_at, issue_end_cursor, mr_updated_at, mr_end_cursor)
- Increased updateGitlabRepos task frequency from daily to hourly
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config.ts | Adds graphqlApiUrl configuration for GitLab GraphQL API endpoint |
| src/cron/tasks/updateGitlabRepos.ts | Updates schema with sync metadata fields, preserves cursor state across updates, increases cron frequency to hourly, adds error handling |
| src/cron/tasks/updateGitlabRepoData/index.ts | Main scheduled task that orchestrates issue and MR synchronization for GitLab repositories |
| src/cron/tasks/updateGitlabRepoData/utils.ts | Utility functions for processing GitLab actors and extracting IDs from GIDs |
| src/cron/tasks/updateGitlabRepoData/getClient.ts | GraphQL client implementation with authentication and error handling |
| src/cron/tasks/updateGitlabRepoData/getIssues.ts | Fetches issues with pagination, including comments and metadata |
| src/cron/tasks/updateGitlabRepoData/getMergeRequests.ts | Fetches merge requests with pagination, including comments, reviewers, and metadata |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: frank-zsy <syzhao1988@126.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new system for synchronizing GitLab repository data (issues and merge requests) using the GitLab GraphQL API. It adds a scheduled task that fetches and stores detailed issue and merge request events, including comments and reviewers, into the database. The implementation includes robust batching, pagination, and error handling to avoid rate limits and ensure data consistency.
Key changes include:
GitLab GraphQL Integration:
graphqlApiUrlfor GitLab inconfig.tsto support GraphQL API requests.getGraphqlClientfunction for authenticated GitLab GraphQL requests, handling errors and pagination.Data Fetching Utilities:
InsertRecordinterface and utility functions (processActor,extractIdFromGid) to standardize data extraction from GraphQL responses.Issue and Merge Request Synchronization:
getIssuesandgetMergeRequestsmodules to fetch all issues and merge requests for a repository, including comments and reviewers, with batching and pagination to handle large datasets and avoid rate limits. [1] [2]Scheduled Task for Data Update:
updateGitlabRepoData/index.tsthat periodically fetches updated issues and merge requests for GitLab repositories, inserts new events into the database, and updates repository sync metadata.Other Improvements: