Skip to content

Commit

Permalink
perf 無駄な join を削減
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Nov 9, 2024
1 parent 0768cac commit 8db7bd1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions webapp/api/oauth/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,15 @@ app.post(
// scope 取得
const requestedScopes = new Set(scope ? scope.split(' ') : [])
const scopes = (
await c.var.dbClient.query.oauthClient.findMany({
where: (oauthClient, { eq }) => eq(oauthClient.id, client_id),
await c.var.dbClient.query.oauthClientScope.findMany({
where: (oauthClientScope, { eq }) =>
eq(oauthClientScope.client_id, client_id),
with: {
scopes: {
with: {
scope: true,
},
},
scope: true,
},
})
)
.map(client => client.scopes.map(scope => scope.scope))
.flat()
.map(clientScope => clientScope.scope)
.filter(data => {
// scope リクエストしてない場合は requestedScopes = [] なので、全部 true として付与
if (requestedScopes.size === 0) return true
Expand Down

0 comments on commit 8db7bd1

Please sign in to comment.