Skip to content

Commit da4d94a

Browse files
authored
Merge branch 'main' into fix-lfs-upload
2 parents 74e5583 + 82071ee commit da4d94a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1170
-897
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ _test
2222
.vscode
2323
__debug_bin*
2424

25+
# Visual Studio
26+
/.vs/
27+
2528
*.cgo1.go
2629
*.cgo2.c
2730
_cgo_defun.c

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ Rowan Bohde <[email protected]> (@bohde)
6464
hiifong <[email protected]> (@hiifong)
6565
metiftikci <[email protected]> (@metiftikci)
6666
Christopher Homberger <[email protected]> (@ChristopherHX)
67+
Tobias Balle-Petersen <[email protected]> (@tobiasbp)

assets/go-licenses.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"strings"
1919
"syscall"
2020

21-
"github.com/google/go-github/v61/github"
21+
"github.com/google/go-github/v71/github"
2222
"github.com/urfave/cli/v2"
2323
"gopkg.in/yaml.v3"
2424
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ require (
6666
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
6767
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
6868
github.com/golang-jwt/jwt/v5 v5.2.2
69-
github.com/google/go-github/v61 v61.0.0
69+
github.com/google/go-github/v71 v71.0.0
7070
github.com/google/licenseclassifier/v2 v2.0.0
7171
github.com/google/pprof v0.0.0-20250422154841-e1f9c1950416
7272
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
420420
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
421421
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
422422
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
423-
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
424-
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
423+
github.com/google/go-github/v71 v71.0.0 h1:Zi16OymGKZZMm8ZliffVVJ/Q9YZreDKONCr+WUd0Z30=
424+
github.com/google/go-github/v71 v71.0.0/go.mod h1:URZXObp2BLlMjwu0O8g4y6VBneUj2bCHgnI8FfgZ51M=
425425
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
426426
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
427427
github.com/google/go-tpm v0.9.3 h1:+yx0/anQuGzi+ssRqeD6WpXjW2L/V0dItUayO0i9sRc=

models/activities/statistic.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ import (
1717
repo_model "code.gitea.io/gitea/models/repo"
1818
user_model "code.gitea.io/gitea/models/user"
1919
"code.gitea.io/gitea/models/webhook"
20+
"code.gitea.io/gitea/modules/optional"
2021
"code.gitea.io/gitea/modules/setting"
2122
)
2223

2324
// Statistic contains the database statistics
2425
type Statistic struct {
2526
Counter struct {
26-
User, Org, PublicKey,
27+
UsersActive, UsersNotActive,
28+
Org, PublicKey,
2729
Repo, Watch, Star, Access,
2830
Issue, IssueClosed, IssueOpen,
2931
Comment, Oauth, Follow,
@@ -53,7 +55,19 @@ type IssueByRepositoryCount struct {
5355
// GetStatistic returns the database statistics
5456
func GetStatistic(ctx context.Context) (stats Statistic) {
5557
e := db.GetEngine(ctx)
56-
stats.Counter.User = user_model.CountUsers(ctx, nil)
58+
59+
// Number of active users
60+
usersActiveOpts := user_model.CountUserFilter{
61+
IsActive: optional.Some(true),
62+
}
63+
stats.Counter.UsersActive = user_model.CountUsers(ctx, &usersActiveOpts)
64+
65+
// Number of inactive users
66+
usersNotActiveOpts := user_model.CountUserFilter{
67+
IsActive: optional.Some(false),
68+
}
69+
stats.Counter.UsersNotActive = user_model.CountUsers(ctx, &usersNotActiveOpts)
70+
5771
stats.Counter.Org, _ = db.Count[organization.Organization](ctx, organization.FindOrgOptions{IncludePrivate: true})
5872
stats.Counter.PublicKey, _ = e.Count(new(asymkey_model.PublicKey))
5973
stats.Counter.Repo, _ = repo_model.CountRepositories(ctx, repo_model.CountRepositoryOptions{})

models/user/user.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ func IsLastAdminUser(ctx context.Context, user *User) bool {
828828
type CountUserFilter struct {
829829
LastLoginSince *int64
830830
IsAdmin optional.Option[bool]
831+
IsActive optional.Option[bool]
831832
}
832833

833834
// CountUsers returns number of users.
@@ -848,6 +849,10 @@ func countUsers(ctx context.Context, opts *CountUserFilter) int64 {
848849
if opts.IsAdmin.Has() {
849850
cond = cond.And(builder.Eq{"is_admin": opts.IsAdmin.Value()})
850851
}
852+
853+
if opts.IsActive.Has() {
854+
cond = cond.And(builder.Eq{"is_active": opts.IsActive.Value()})
855+
}
851856
}
852857

853858
count, err := sess.Where(cond).Count(new(User))

modules/metrics/collector.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func NewCollector() Collector {
184184
Users: prometheus.NewDesc(
185185
namespace+"users",
186186
"Number of Users",
187-
nil, nil,
187+
[]string{"state"}, nil,
188188
),
189189
Watches: prometheus.NewDesc(
190190
namespace+"watches",
@@ -373,7 +373,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
373373
ch <- prometheus.MustNewConstMetric(
374374
c.Users,
375375
prometheus.GaugeValue,
376-
float64(stats.Counter.User),
376+
float64(stats.Counter.UsersActive),
377+
"active", // state label
378+
)
379+
ch <- prometheus.MustNewConstMetric(
380+
c.Users,
381+
prometheus.GaugeValue,
382+
float64(stats.Counter.UsersNotActive),
383+
"inactive", // state label
377384
)
378385
ch <- prometheus.MustNewConstMetric(
379386
c.Watches,

0 commit comments

Comments
 (0)