Skip to content

Commit

Permalink
fix(Dashboard): filter by dates works
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Jun 20, 2024
1 parent b191af1 commit 5902246
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions trpc/queries/projectV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export const getUserProjectsWithGoals = (params: GetProjectsWithGoalsByIdsParams
eb('Goal.activityId', '=', params.activityId),
]),
)
.where(({ or, and, eb, val, selectFrom }) => {
.where(({ or, and, eb, selectFrom, cast, val }) => {
const { goalsQuery } = params;
const estimate: Array<Date> = [];

Expand Down Expand Up @@ -395,10 +395,10 @@ export const getUserProjectsWithGoals = (params: GetProjectsWithGoalsByIdsParams
// eslint-disable-next-line no-nested-ternary
estimate.length > 0
? estimate.length === 1
? eb('Goal.estimate', '=', val<Date>(estimate[0]))
? eb('Goal.estimate', '=', cast<Date>(val<Date>(estimate[0]), 'date'))
: and([
eb('Goal.estimate', '>=', val<Date>(estimate[0])),
eb('Goal.estimate', '<=', val<Date>(estimate[1])),
eb('Goal.estimate', '>=', cast<Date>(val<Date>(estimate[0]), 'date')),
eb('Goal.estimate', '<=', cast<Date>(val<Date>(estimate[1]), 'date')),
])
: null,
query: or([
Expand Down Expand Up @@ -496,12 +496,8 @@ export const getUserProjectsWithGoals = (params: GetProjectsWithGoalsByIdsParams
.where('Project.archived', 'is not', true)
.where(({ or, eb }) =>
or([
eb('Project.id', 'in', ({ selectFrom }) => selectFrom('goals').select('goals.projectId')),
eb('Project.id', 'in', ({ selectFrom }) => selectFrom('project_ids').select('pid')),
eb('Project.id', 'in', ({ selectFrom }) =>
selectFrom('Goal')
.select('Goal.projectId as pid')
.where('Goal.id', 'in', ({ selectFrom }) => selectFrom('subs_goals').select('B')),
),
]),
)
.groupBy('Project.id')
Expand Down

0 comments on commit 5902246

Please sign in to comment.