[PR #827] [MERGED] Avoid duplicate queries in auth #15595

Closed
opened 2025-11-02 11:50:14 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/827
Author: @ethantkoenig
Created: 2/2/2017
Status: Merged
Merged: 2/5/2017
Merged by: @lunny

Base: masterHead: refactor/auth


📝 Commits (1)

  • 9b1b986 Avoid duplicate queries in auth

📊 Changes

1 file changed (+48 additions, -57 deletions)

View changed files

📝 modules/auth/auth.go (+48 -57)

📄 Description

In the common case, two identical calls to GetUserByID(..) are made when SignedInUser(..) is called: one by SignedInID(..) (which SignedInUser(..) calls), and another by SignedInUser(..) itself.

I've refactored the code so that only at most one call to GetUserByID(..) is made. I also think it makes GetUserByID(..) a little more readable, since I was able to "get rid of" a long if statement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/827 **Author:** [@ethantkoenig](https://github.com/ethantkoenig) **Created:** 2/2/2017 **Status:** ✅ Merged **Merged:** 2/5/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `refactor/auth` --- ### 📝 Commits (1) - [`9b1b986`](https://github.com/go-gitea/gitea/commit/9b1b986091b507c95f3b4dffc3852946651afbb4) Avoid duplicate queries in auth ### 📊 Changes **1 file changed** (+48 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `modules/auth/auth.go` (+48 -57) </details> ### 📄 Description In the common case, two identical calls to `GetUserByID(..)` are made when `SignedInUser(..)` is called: one by `SignedInID(..)` (which `SignedInUser(..)` calls), and another by `SignedInUser(..)` itself. I've refactored the code so that only at most one call to `GetUserByID(..)` is made. I also think it makes `GetUserByID(..)` a little more readable, since I was able to "get rid of" a long if statement. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 11:50:14 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15595