Skip to content

chore: patched code smells in prod code and tests - #588

Merged
petruki merged 1 commit into
masterfrom
staging
Oct 4, 2026
Merged

petruki merged 1 commit into
masterfrom
staging

Conversation

@petruki

@petruki petruki commented Oct 4, 2026

Copy link
Copy Markdown
Member

This pull request focuses on optimizing permission checks, database operations, and batch processing by replacing sequential for/for...of loops with concurrent Promise.all and for await constructs where appropriate. These changes improve performance, especially for operations that involve multiple asynchronous database calls. Additionally, there are minor code cleanups and consistency improvements.

Performance Improvements and Refactoring:

  • Batch Permission and Ownership Checks:

    • Rewrote permission resolution and ownership verification logic in resolvePermission, verifyOwnership, and related endpoints to use Promise.all for concurrent permission checks, reducing latency when verifying multiple actions or teams. [1] [2] [3]
  • Concurrent Database Updates and Deletions:

    • Updated all model hooks (e.g., in component.js, config.js, domain.js, group-config.js, team.js, admin.js) to use Promise.all for saving or deleting multiple related documents, instead of sequentially awaiting each operation. [1] [2] [3] [4] [5] [6] [7]
  • Concurrent Processing in GitOps Services:

    • Refactored functions in services/gitops (such as pushChanges, processComponentDeleted, processNewComponent) to process multiple changes concurrently with Promise.all or for await, improving deployment and synchronization speed. [1] [2] [3] [4] [5]

Code Consistency and Minor Improvements:

  • Consistency in Array Checks:

    • Replaced .find(...) with .includes(...) and similar adjustments for clearer intent and slightly improved performance in value checks. [1] [2]
  • Ensured Await on Critical Saves:

    • Added missing await keywords to ensure domain/environment version updates and saves are completed before proceeding. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Other Minor Cleanups:

  • Replaced .find with .some for validation logic for improved readability.
  • Used for await in population functions for consistency with async iteration. [1] [2]

These changes collectively improve the efficiency, maintainability, and reliability of permission handling and batch operations throughout the codebase.

@petruki petruki added this to the v1.4.1 milestone Oct 4, 2026
@petruki petruki self-assigned this Oct 4, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change labels Oct 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Comment thread src/aggregator/resolvers.js Dismissed
@petruki
petruki merged commit e19f161 into master Oct 4, 2026
5 checks passed
@petruki
petruki deleted the staging branch October 4, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants