taskany-inc / issues

The simplest task manager ever. Love planning again 🐑
http://taskany.org
MIT License
16 stars 8 forks source link

Renew filters for goals/dashboard/project #1860

Open LamaEats opened 1 year ago

9teen90nine commented 1 year ago

Currently couple params are passed both in URL and via props. Could be simplified by using a cache or a context.

Ex.: https://github.com/taskany-inc/issues/blob/main/src/components/FilteredPage/FilteredPage.tsx#L73C9-L73C27 https://github.com/taskany-inc/issues/blob/main/src/hooks/useFiltersPreset.ts https://github.com/taskany-inc/issues/blob/main/src/hooks/useUrlFilterParams.ts

9teen90nine commented 1 year ago

some thoughts in sql:

select *    
from "Activity"
left join "User"
    on "User"."activityId" = "Activity".id
left join "Goal" 
    on "Goal"."activityId" = "Activity".id
left join "Priority"
    on "Goal"."priorityId" = "Priority".id
inner join (
    VALUES ('dsagfsabgbt', ARRAY['cl6z1n4yd128323bhcpxhfguto', 'cl6yv5o0600433bd7h3czz21g'], ARRAY['2', '3'])
) as filter_query (id, issuers, priorities)
    on ("Activity".id = any(filter_query.issuers) or filter_query.issuers is null) and "Priority".id = any(filter_query.priorities)
awinogradov commented 1 year ago

model GoalView { id String @id @default(cuid()) title? String issuer String[] sort: group: }

// ?filterId=1231

issuer: [4123, 1231]

issuer: [{ id: 124124 }]

// Raw SQL // row 1 with inner join of preset data const preset = { id: 1231 issuer: [4123, 1231] }

// row 2 prisma.goal.findMany({ where: { activityId: { in: preset.issuer } } })

interface PageViewContext { queryParams: { id?: string; issuer: string[]; sort: string[]; groupBy: string[]; }; viewPrams: { mode: list, kanban } }

- filter actions -> onApply -> filterContext.update({ issuer: [123, 1412], })

-> trpc.useQuery({ ...filterContext.queryParams })