-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Refactored query result getter handlers to support recursivity #8497
Open
lucasbordeau
wants to merge
12
commits into
main
Choose a base branch
from
fix/upload-picture-bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+277
−34
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b9608cd
Fixed getImageAbsoluteURI in local
lucasbordeau 025a135
Added TODO
lucasbordeau c7efc99
WIP
lucasbordeau 6f40e39
Finished
lucasbordeau 130cd55
Fixes
lucasbordeau 822a645
Fix
lucasbordeau add4a58
Fix
lucasbordeau a78b297
Fix
lucasbordeau ea89cc3
Added more protection
lucasbordeau d83400b
Fixed logging
lucasbordeau 1f6663a
Merge branch 'main' into fix/upload-picture-bugs
Weiko c298be7
fix after merge
Weiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
8 changes: 8 additions & 0 deletions
8
...kspace-query-runner/factories/query-result-getters/interfaces/query-result-field-value.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
import { IConnection } from 'src/engine/api/graphql/workspace-query-runner/interfaces/connection.interface'; | ||
|
||
export type QueryResultFieldValue = | ||
| IConnection<ObjectRecord> | ||
| { records: ObjectRecord[] } | ||
| ObjectRecord | ||
| ObjectRecord[]; |
7 changes: 6 additions & 1 deletion
7
...runner/factories/query-result-getters/interfaces/query-result-getter-handler.interface.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
|
||
export interface QueryResultGetterHandlerInterface { | ||
handle(result: any, workspaceId: string): Promise<any>; | ||
handle( | ||
objectRecord: ObjectRecord, | ||
workspaceId: string, | ||
): Promise<ObjectRecord>; | ||
} |
This file contains 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
10 changes: 10 additions & 0 deletions
10
...er/factories/query-result-getters/utils/is-query-result-field-value-a-connection.guard.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
import { QueryResultFieldValue } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-field-value'; | ||
import { IConnection } from 'src/engine/api/graphql/workspace-query-runner/interfaces/connection.interface'; | ||
import { IEdge } from 'src/engine/api/graphql/workspace-query-runner/interfaces/edge.interface'; | ||
|
||
export const isQueryResultFieldValueAConnection = ( | ||
result: QueryResultFieldValue, | ||
): result is IConnection<ObjectRecord, IEdge<ObjectRecord>> => { | ||
return 'edges' in result && Array.isArray(result.edges); | ||
}; |
8 changes: 8 additions & 0 deletions
8
...ies/query-result-getters/utils/is-query-result-field-value-a-nested-record-array.guard.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
import { QueryResultFieldValue } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-field-value'; | ||
|
||
export const isQueryResultFieldValueANestedRecordArray = ( | ||
result: QueryResultFieldValue, | ||
): result is { records: ObjectRecord[] } => { | ||
return 'records' in result && Array.isArray(result.records); | ||
}; |
8 changes: 8 additions & 0 deletions
8
.../factories/query-result-getters/utils/is-query-result-field-value-a-record-array.guard.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
import { QueryResultFieldValue } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-field-value'; | ||
|
||
export const isQueryResultFieldValueARecordArray = ( | ||
result: QueryResultFieldValue, | ||
): result is ObjectRecord[] => { | ||
return Array.isArray(result); | ||
}; |
8 changes: 8 additions & 0 deletions
8
...runner/factories/query-result-getters/utils/is-query-result-field-value-a-record.guard.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface'; | ||
import { QueryResultFieldValue } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-field-value'; | ||
|
||
export const isQueryResultFieldValueARecord = ( | ||
result: QueryResultFieldValue, | ||
): result is ObjectRecord[] => { | ||
return 'id' in result && 'createdAt' in result && 'updatedAt' in result; | ||
}; |
6 changes: 3 additions & 3 deletions
6
packages/twenty-server/src/engine/core-modules/logger/logger.module.ts
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { Logger } from '@nestjs/common'; | ||
|
||
import { isDefined } from 'class-validator'; | ||
|
||
/** | ||
* A decorator function that logs the execution time of the decorated method. | ||
* | ||
* @returns The modified property descriptor with the execution time logging functionality. | ||
*/ | ||
export function LogExecutionTime() { | ||
export function LogExecutionTime(label?: string | undefined) { | ||
return function ( | ||
target: any, | ||
propertyKey: string, | ||
|
@@ -21,7 +23,11 @@ export function LogExecutionTime() { | |
const end = performance.now(); | ||
const executionTime = end - start; | ||
|
||
logger.log(`Execution time: ${executionTime.toFixed(2)}ms`); | ||
if (isDefined(label)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: isDefined() will return true for empty strings - consider using a more strict check like |
||
logger.log(`${label} execution time: ${executionTime.toFixed(2)}ms`); | ||
} else { | ||
logger.log(`Execution time: ${executionTime.toFixed(2)}ms`); | ||
} | ||
|
||
return result; | ||
}; | ||
|
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: The type annotation
string | undefined
is redundant when using optional parameter syntax?