Skip to content

Commit 548cd0c

Browse files
GustedEarl Warren
authored andcommitted
feat: avoid expensive SQL for org home (go-gitea#9309)
This change comes from Codeberg's Forgejo fork and has been in deployed in production for a month now. (https://codeberg.org/Codeberg-Infrastructure/forgejo/commit/de372975c703b1368ce6d538de1b21f20c6f3a84) What we noticed on Codeberg is that navigating to the organisation's home was quite slow, for example https://codeberg.org/forgejo, this was caused by searching for the repositories that is owned by the organisation. The expensive part of this SQL was that it tried to show repositories where the organisation is a collaborator of... which is none as you cannot add organisations as a collaborator. Not doing this made the SQL query very fast again. There's no test associated with this, as it's essentially a no-op before and after. So no testing would fail without this change. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9309 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
1 parent 3041343 commit 548cd0c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

routers/web/org/home.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"forgejo.org/modules/log"
2020
"forgejo.org/modules/markup"
2121
"forgejo.org/modules/markup/markdown"
22+
"forgejo.org/modules/optional"
2223
"forgejo.org/modules/setting"
2324
"forgejo.org/modules/util"
2425
shared_user "forgejo.org/routers/web/shared/user"
@@ -101,6 +102,7 @@ func Home(ctx *context.Context) {
101102
},
102103
Keyword: keyword,
103104
OwnerID: org.ID,
105+
Collaborate: optional.Some(false), // A organisation doesn't collaborate to any repository, avoid doing expensive SQL query.
104106
OrderBy: orderBy,
105107
Private: ctx.IsSigned,
106108
Actor: ctx.Doer,

0 commit comments

Comments
 (0)