Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ORM #6363

Merged
merged 2 commits into from
Jul 22, 2024
Merged

Fix ORM #6363

merged 2 commits into from
Jul 22, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Jul 22, 2024

This PR fixes a few bugs on TwentyORM:

  • fix many to one relations that were not properly queries
  • fix many to one relations that were not properly parsed
  • compute datasource (or use from cache) at run-time and do not use injected one that could be outdated

We still need to refactor it to simplify, I feel the API are too complex and we have too many cache layers. Also the relation computation part is very complex and bug prone

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The pull request focuses on enhancing the ORM's robustness and maintainability by refactoring and improving code organization.

  • workspace.repository.ts: Reordered imports and modified getObjectMetadataFromTarget to handle string targets, improving code readability and robustness.
  • twenty-orm.manager.ts: Refactored to modularize code, introducing buildRepositoryForWorkspace and buildDatasourceForWorkspace methods, reducing duplication and enhancing clarity.
  • calendar-save-events.service.ts: Replaced direct workspaceDataSource usage with this.twentyORMManager.getWorkspaceDatasource(), ensuring up-to-date data sources and transactional integrity.
  • calendar-event-participant-manager.module.ts: Added WorkspaceModule to imports, ensuring necessary dependencies are included.
  • calendar-event-participant-match-participant.job.ts: Introduced WorkspaceService to check workspace activation before processing, improving performance and avoiding unnecessary operations.

5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@charlesBochet charlesBochet merged commit d212aed into main Jul 22, 2024
6 checks passed
@charlesBochet charlesBochet deleted the fix-orm branch July 22, 2024 13:07
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