c572fcfe04
Rename the Go module path from code.gitea.io/gitea to git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire codebase. Scope: - go.mod module declaration - 2,235 Go source files (import paths) - Dockerfile WORKDIR and COPY paths - Swagger API templates - golangci.yml linter config External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea, gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are separate upstream modules. Closes #132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
957 B
Go
49 lines
957 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/db"
|
|
)
|
|
|
|
func GetUsersMapByIDs(ctx context.Context, userIDs []int64) (map[int64]*User, error) {
|
|
userMaps := make(map[int64]*User, len(userIDs))
|
|
if len(userIDs) == 0 {
|
|
return userMaps, nil
|
|
}
|
|
|
|
left := len(userIDs)
|
|
for left > 0 {
|
|
limit := min(left, db.DefaultMaxInSize)
|
|
err := db.GetEngine(ctx).
|
|
In("id", userIDs[:limit]).
|
|
Find(&userMaps)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
left -= limit
|
|
userIDs = userIDs[limit:]
|
|
}
|
|
return userMaps, nil
|
|
}
|
|
|
|
func GetPossibleUserFromMap(userID int64, usererMaps map[int64]*User) *User {
|
|
switch userID {
|
|
case GhostUserID:
|
|
return NewGhostUser()
|
|
case ActionsUserID:
|
|
return NewActionsUser()
|
|
case 0:
|
|
return nil
|
|
default:
|
|
user, ok := usererMaps[userID]
|
|
if !ok {
|
|
return NewGhostUser()
|
|
}
|
|
return user
|
|
}
|
|
}
|