graasp / graasp/graasp-api

Optimize accessible

Open
#1,462 0 comments 0 reactions 0 assignees View on GitHub
question refactor
Dominant language
TypeScript
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

I think this query is more efficient than the current one.

But it's "difficult" to refactor because we currently get itemmemberships, which helps building packed items later. Starting by the table item with typeorm forces you to only get item. Might work if it had a relation `item_memberships`

Also typeorm cannot translate well the `With As` syntax.

```
-- WITH r AS
-- (SELECT i.id, i.path, row_number() OVER (ORDER BY path) rn FROM "item" "i" INNER JOIN "item_membership" "im" ON "i"."path" = "im"."item_path" AND "im"."account_id" = WHERE "i"."deleted_at" IS NULL ORDER BY "i"."path" ASC)
-- SELECT *
-- FROM r "a"
-- WHERE rn <= (SELECT rn FROM r WHERE r.path @> a.path order by rn limit 1);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.