Skip to content
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

UserEntityService.getRelations()の書き方をメモリに優しい形にする #13810

Closed
1 task done
samunohito opened this issue May 8, 2024 · 0 comments · Fixed by #13811
Closed
1 task done
Assignees
Labels
🔥high priority packages/backend Server side specific issue/PR 🐢Performance Efficiency related issue/PR 💚Refactor Rewriting code without changing behavior

Comments

@samunohito
Copy link
Member

Summary

this.followingsRepository.findBy({ followerId: me })
.then(f => new Map(f.map(it => [it.followeeId, it]))),
this.followingsRepository.findBy({ followeeId: me })
.then(it => it.map(it => it.followerId)),
this.followRequestsRepository.findBy({ followerId: me })
.then(it => it.map(it => it.followeeId)),
this.followRequestsRepository.findBy({ followeeId: me })
.then(it => it.map(it => it.followerId)),
this.blockingsRepository.findBy({ blockerId: me })
.then(it => it.map(it => it.blockeeId)),
this.blockingsRepository.findBy({ blockeeId: me })
.then(it => it.map(it => it.blockerId)),
this.mutingsRepository.findBy({ muterId: me })
.then(it => it.map(it => it.muteeId)),
this.renoteMutingsRepository.findBy({ muterId: me })
.then(it => it.map(it => it.muteeId)),

使用しているのは各IDのみなので、エンティティをまるまる作る形ではなく、
.select(['followerId']).getRawMany() のような形にして余計な値を読まないようにする

Purpose

パフォーマンス改善

Do you want to implement this feature yourself?

  • Yes, I will implement this by myself and send a pull request
@samunohito samunohito added 🐢Performance Efficiency related issue/PR packages/backend Server side specific issue/PR 💚Refactor Rewriting code without changing behavior 🔥high priority labels May 8, 2024
@samunohito samunohito self-assigned this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥high priority packages/backend Server side specific issue/PR 🐢Performance Efficiency related issue/PR 💚Refactor Rewriting code without changing behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant