Skip to content

Conversation

@mbani01
Copy link
Contributor

@mbani01 mbani01 commented Jan 19, 2026

This pull request refactors and consolidates repository mapping logic across several backend services and data access layers, improving consistency and maintainability. The main changes include replacing platform-specific functions with generic ones, updating queries to use the unified public.repositories table, and standardizing how mapped repositories are checked and retrieved for segments.

Refactoring and consolidation of repository mapping logic:

  • Replaced platform-specific functions (getGithubMappedRepos, getGitlabMappedRepos, etc.) with generic functions (getMappedRepos, getRepoUrlsMappedToOtherSegments, hasMappedRepos, getMappedWithSegmentName) in services/libs/data-access-layer/src/segments/index.ts, simplifying code and reducing duplication. [1] [2]
  • Updated SQL queries to use the unified public.repositories table for all platforms, improving query consistency and future scalability. [1] [2]

Backend service updates for new mapping logic:

  • Refactored backend services (SegmentRepository, CollectionService, IntegrationService, CommonIntegrationService) to use the new generic mapping functions, removing legacy methods and updating logic to support multiple platforms (GitHub, GitHub Nango, GitLab). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Removal of legacy methods:

  • Removed legacy methods (hasMappedRepos, mappedWith, getGithubMappedRepos, getGitlabMappedRepos, etc.) from repositories and services, fully transitioning to the new generic approach. [1] [2] [3]

Platform support improvements:

  • Added support for additional platforms (e.g., PlatformType.GITHUB_NANGO) in repository mapping checks and queries, ensuring broader compatibility. [1] [2] [3]

Codebase consistency and maintainability:

  • Standardized function signatures and usage across the codebase, improving readability and making future changes easier to implement. [1] [2] [3]

These changes collectively modernize and streamline how repository mappings are handled for segments, setting a foundation for easier future enhancements and platform support.


Note

Modernizes repo-mapping by standardizing reads/writes on the unified public.repositories table and replacing platform-specific code with generic utilities.

  • Introduces generic helpers in segments: getMappedRepos, getRepoUrlsMappedToOtherSegments, hasMappedRepos, getMappedWithSegmentName; queries now target public.repositories
  • Updates SegmentRepository, CollectionService, IntegrationService, and common services to use new helpers (adds support for PlatformType.GITHUB_NANGO); integrates into widgets/progress and mapped-repo displays
  • Removes legacy per-platform reads/methods (e.g., getGithubRepos, getGitlabRepos, hasMappedRepos, mappedWith, repository getMapping on GitHub/GitLab repos repositories)
  • Keeps legacy insert/delete paths for GitHub/GitLab mappings but eliminates read paths; centralizes conflict checks and cross-segment validations via DAL

Written by Cursor Bugbot for commit d71977e. This will update automatically on new commits. Configure here.

@mbani01 mbani01 requested a review from ulemons January 19, 2026 17:09
@mbani01 mbani01 self-assigned this Jan 19, 2026
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

2 similar comments
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@mbani01 mbani01 changed the title chore: migrate-repo-reads-to-public-repositories chore: migrate-repo-reads-to-public-repositories [CM-900] Jan 20, 2026
return results
}

static async hasMappedRepos(segmentId: string, options: IRepositoryOptions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this function still used ? should t we have a centralized one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch it's a dead code, I already added a centralized one

return results
}

static async hasMappedRepos(segmentId: string, options: IRepositoryOptions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same of above, should we keep this specific function ?

@ulemons
Copy link
Contributor

ulemons commented Jan 20, 2026

LGTM ✅

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.

3 participants