Repository navigation
#4469 prisma query optimization #4582
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
Open
getheobald
wants to merge
15
commits into
develop
Choose a base branch
from
#4469-prisma-query-optimization
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a6b2f3b
holder for benchmarking logs
getheobald fbd7109
query changes weee
getheobald 07546d9
Merge branch '#4469-prisma-query-optimization' of https://github.com/…
getheobald 1746ead
editing early return fix
getheobald 9b85a95
one slot only, pick earliest date
getheobald 9dafc85
remove unnecessary ordering
getheobald 664c404
assignee ordering fix
getheobald e35659d
remove deleted by, have prisma get type from query args
getheobald e28e468
gantt base type
getheobald 47bd3cc
Merge remote-tracking branch 'origin/develop' into #4469-prisma-query…
getheobald 5548232
slim task type
getheobald c98d014
bar and CR modal stacking bug fix
getheobald f04e02d
revert temp change
getheobald 1527325
one-line fix for #4477 drag-to-edit bug
getheobald 85a42c3
revert to userpreviewqueryargs and revert fullnamepipe accordingly
getheobald 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 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
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
93 changes: 93 additions & 0 deletions
93
src/backend/src/prisma-query-args/gantt-chart.query-args.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { Prisma } from '@prisma/client'; | ||
| import { getUserPreviewQueryArgs } from './user.query-args.js'; | ||
|
|
||
| // Base gantt chart query: only what the gantt chart reads (see the GanttChart* types in shared). | ||
| // Other gantt views (e.g. retrospective) can extend these instead of starting from the full project query. | ||
|
|
||
| export type GanttChartTaskQueryArgs = ReturnType<typeof getGanttChartTaskQueryArgs>; | ||
| export type GanttChartEventQueryArgs = ReturnType<typeof getGanttChartEventQueryArgs>; | ||
| export type GanttChartWorkPackageQueryArgs = ReturnType<typeof getGanttChartWorkPackageQueryArgs>; | ||
| export type GanttChartProjectQueryArgs = ReturnType<typeof getGanttChartProjectQueryArgs>; | ||
|
|
||
| const wbsNumberSelect = { carNumber: true, projectNumber: true, workPackageNumber: true } as const; | ||
|
|
||
| // a task bar and its tooltip; saving an edited task reads its other fields from the full project | ||
| export const getGanttChartTaskQueryArgs = () => | ||
|
Contributor
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. this and event preview are nearly identical |
||
| Prisma.validator<Prisma.TaskDefaultArgs>()({ | ||
| select: { | ||
| taskId: true, | ||
| title: true, | ||
| status: true, | ||
| startDate: true, | ||
| deadline: true, | ||
| wbsElement: { select: wbsNumberSelect }, | ||
| createdBy: getUserPreviewQueryArgs(), | ||
| assignees: getUserPreviewQueryArgs() | ||
| } | ||
| }); | ||
|
|
||
| export const getGanttChartEventQueryArgs = () => | ||
| Prisma.validator<Prisma.EventDefaultArgs>()({ | ||
| select: { | ||
| eventId: true, | ||
| status: true, | ||
| initialDateScheduled: true, | ||
| // the event marker shows one date, so just fetch the earliest slot | ||
| scheduledTimes: { select: { startTime: true }, orderBy: { startTime: 'asc' }, take: 1 } | ||
| } | ||
| }); | ||
|
|
||
| export const getGanttChartWorkPackageQueryArgs = () => | ||
| Prisma.validator<Prisma.Work_PackageDefaultArgs>()({ | ||
| select: { | ||
| workPackageId: true, | ||
| wbsElementId: true, | ||
| projectId: true, | ||
| startDate: true, | ||
| duration: true, | ||
| stage: true, | ||
| wbsElement: { | ||
| select: { | ||
| ...wbsNumberSelect, | ||
| name: true, | ||
| status: true, | ||
| dateCreated: true, | ||
| dateDeleted: true, | ||
| lead: getUserPreviewQueryArgs(), | ||
| manager: getUserPreviewQueryArgs(), | ||
| blocking: { where: { wbsElement: { dateDeleted: null } }, select: { wbsElement: { select: wbsNumberSelect } } } | ||
| } | ||
| }, | ||
| events: { where: { dateDeleted: null }, ...getGanttChartEventQueryArgs() } | ||
| } | ||
| }); | ||
|
|
||
| export const getGanttChartProjectQueryArgs = () => | ||
| Prisma.validator<Prisma.ProjectDefaultArgs>()({ | ||
| select: { | ||
| projectId: true, | ||
| wbsElementId: true, | ||
| wbsElement: { | ||
| select: { | ||
| ...wbsNumberSelect, | ||
| name: true, | ||
| dateCreated: true, | ||
| dateDeleted: true, | ||
| lead: getUserPreviewQueryArgs(), | ||
| manager: getUserPreviewQueryArgs(), | ||
| tasks: { | ||
| where: { dateDeleted: null }, | ||
| orderBy: [{ dateCreated: 'asc' }, { taskId: 'asc' }], | ||
| ...getGanttChartTaskQueryArgs() | ||
| } | ||
| } | ||
| }, | ||
| teams: { select: { teamId: true } }, | ||
| workPackages: { | ||
| where: { wbsElement: { dateDeleted: null } }, | ||
| // orderInProject can repeat after a work package is deleted, so tie-break on the (unique per project) wp number | ||
| orderBy: [{ orderInProject: 'asc' }, { wbsElement: { workPackageNumber: 'asc' } }], | ||
| ...getGanttChartWorkPackageQueryArgs() | ||
| } | ||
| } | ||
| }); | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { Prisma } from '@prisma/client'; | |
| import { getUserPreviewWithEmailQueryArgs, getUserQueryArgs } from './user.query-args.js'; | ||
|
|
||
| export type TaskQueryArgs = ReturnType<typeof getTaskQueryArgs>; | ||
| export type TaskGanttQueryArgs = ReturnType<typeof getTaskGanttQueryArgs>; | ||
| export type TaskPreviewQueryArgs = ReturnType<typeof getTaskPreviewQueryArgs>; | ||
| export type CalendarTaskQueryArgs = ReturnType<typeof getCalendarTaskQueryArgs>; | ||
| export type TaskLabelQueryArgs = ReturnType<typeof getTaskLabelQueryArgs>; | ||
|
|
@@ -60,6 +61,26 @@ export const getTaskQueryArgs = () => | |
| } | ||
| }); | ||
|
|
||
| // same output as getTaskQueryArgs through taskTransformer for the gantt's tasks, which are non-deleted (so deletedBy is | ||
| // skipped) and project-level (a project's wbs element has no work package, so its blocking work packages are skipped) | ||
| export const getTaskGanttQueryArgs = () => | ||
|
Contributor
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. I don't think this is different enough from the preview or potentially this could just replace the preview |
||
| Prisma.validator<Prisma.TaskDefaultArgs>()({ | ||
| include: { | ||
| createdBy: getUserPreviewWithEmailQueryArgs(), | ||
| assignees: getUserPreviewWithEmailQueryArgs(), | ||
| labels: getTaskLabelQueryArgs(), | ||
| blockedBy: getTaskBlockedByQueryArgs(), | ||
| wbsElement: { | ||
| select: { | ||
| carNumber: true, | ||
| projectNumber: true, | ||
| workPackageNumber: true, | ||
| name: true | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| export const getCalendarTaskQueryArgs = () => | ||
| Prisma.validator<Prisma.TaskDefaultArgs>()({ | ||
| include: { | ||
|
|
||
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
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
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
2 changes: 2 additions & 0 deletions
2
src/backend/src/prisma/migrations/20261005023559_schedule_slot_event_id_index/migration.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- CreateIndex | ||
| CREATE INDEX "Schedule_Slot_eventId_idx" ON "Schedule_Slot"("eventId"); |
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
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
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
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.
new query arg