Skip to content

Commit 404ba73

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Update Bluemonday to v1.0.19 (go-gitea#20199) Refix indices on actions table (go-gitea#20158)
2 parents dd5740a + 9d9bf66 commit 404ba73

File tree

7 files changed

+68
-63
lines changed

7 files changed

+68
-63
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ require (
6666
github.com/mattn/go-isatty v0.0.14
6767
github.com/mattn/go-sqlite3 v1.14.12
6868
github.com/mholt/archiver/v3 v3.5.1
69-
github.com/microcosm-cc/bluemonday v1.0.18
69+
github.com/microcosm-cc/bluemonday v1.0.19
7070
github.com/minio/minio-go/v7 v7.0.26
7171
github.com/msteinert/pam v1.0.0
7272
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
@@ -93,9 +93,9 @@ require (
9393
go.jolheiser.com/hcaptcha v0.0.4
9494
go.jolheiser.com/pwn v0.0.3
9595
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122
96-
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
96+
golang.org/x/net v0.0.0-20220630215102-69896b714898
9797
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
98-
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6
98+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
9999
golang.org/x/text v0.3.7
100100
golang.org/x/tools v0.1.10
101101
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df

go.sum

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@ github.com/mholt/acmez v1.0.2 h1:C8wsEBIUVi6e0DYoxqCcFuXtwc4AWXL/jgcDjF7mjVo=
11541154
github.com/mholt/acmez v1.0.2/go.mod h1:8qnn8QA/Ewx8E3ZSsmscqsIjhhpxuy9vqdgbX2ceceM=
11551155
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
11561156
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
1157-
github.com/microcosm-cc/bluemonday v1.0.18 h1:6HcxvXDAi3ARt3slx6nTesbvorIc3QeTzBNRvWktHBo=
1158-
github.com/microcosm-cc/bluemonday v1.0.18/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM=
1157+
github.com/microcosm-cc/bluemonday v1.0.19 h1:OI7hoF5FY4pFz2VA//RN8TfM0YJ2dJcl4P4APrCWy6c=
1158+
github.com/microcosm-cc/bluemonday v1.0.19/go.mod h1:QNzV2UbLK2/53oIIwTOyLUSABMkjZ4tqiyC1g/DyqxE=
11591159
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
11601160
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
11611161
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
@@ -1793,14 +1793,13 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
17931793
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17941794
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17951795
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1796-
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17971796
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17981797
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17991798
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18001799
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18011800
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
1802-
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
1803-
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
1801+
golang.org/x/net v0.0.0-20220630215102-69896b714898 h1:K7wO6V1IrczY9QOQ2WkVpw4JQSwCd52UsxVEirZUfiw=
1802+
golang.org/x/net v0.0.0-20220630215102-69896b714898/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
18041803
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
18051804
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
18061805
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1947,8 +1946,8 @@ golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBc
19471946
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
19481947
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
19491948
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1950-
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
1951-
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1949+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
1950+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
19521951
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
19531952
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
19541953
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=

models/action.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ func init() {
9292

9393
// TableIndices implements xorm's TableIndices interface
9494
func (a *Action) TableIndices() []*schemas.Index {
95+
repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
96+
repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
97+
9598
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
9699
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
97100

98-
repoIndex := schemas.NewIndex("r_c_u_d", schemas.IndexType)
99-
repoIndex.AddColumn("repo_id", "created_unix", "user_id", "is_deleted")
100-
101101
return []*schemas.Index{actUserIndex, repoIndex}
102102
}
103103

models/migrations/migrations.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ type Version struct {
5656
Version int64
5757
}
5858

59+
// Use noopMigration when there is a migration that has been no-oped
60+
var noopMigration = func(_ *xorm.Engine) error { return nil }
61+
5962
// This is a sequence of migrations. Add new migrations to the bottom of the list.
6063
// If you want to "retire" a migration, remove it from the top of the list and
6164
// update minDBVersion accordingly
@@ -351,7 +354,7 @@ var migrations = []Migration{
351354
// v198 -> v199
352355
NewMigration("Add issue content history table", addTableIssueContentHistory),
353356
// v199 -> v200
354-
NewMigration("No-op (remote version is using AppState now)", addRemoteVersionTableNoop),
357+
NewMigration("No-op (remote version is using AppState now)", noopMigration),
355358
// v200 -> v201
356359
NewMigration("Add table app_state", addTableAppState),
357360
// v201 -> v202
@@ -388,9 +391,11 @@ var migrations = []Migration{
388391
// v215 -> v216
389392
NewMigration("allow to view files in PRs", addReviewViewedFiles),
390393
// v216 -> v217
391-
NewMigration("Improve Action table indices", improveActionTableIndices),
394+
NewMigration("No-op (Improve Action table indices v1)", noopMigration),
392395
// v217 -> v218
393396
NewMigration("Alter hook_task table TEXT fields to LONGTEXT", alterHookTaskTextFieldsToLongText),
397+
// v218 -> v219
398+
NewMigration("Improve Action table indices v2", improveActionTableIndices),
394399
}
395400

396401
// GetCurrentDBVersion returns the current db version

models/migrations/v199.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
10-
11-
func addRemoteVersionTableNoop(x *xorm.Engine) error {
12-
// we used to use a table `remote_version` to store information for updater, now we use `AppState`, so this migration task is a no-op now.
13-
return nil
14-
}
7+
// We used to use a table `remote_version` to store information for updater, now we use `AppState`, so this migration task is a no-op now.

models/migrations/v216.go

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,5 @@
44

55
package migrations
66

7-
import (
8-
"code.gitea.io/gitea/modules/timeutil"
9-
10-
"xorm.io/xorm"
11-
"xorm.io/xorm/schemas"
12-
)
13-
14-
type improveActionTableIndicesAction struct {
15-
ID int64 `xorm:"pk autoincr"`
16-
UserID int64 // Receiver user id.
17-
OpType int
18-
ActUserID int64 // Action user id.
19-
RepoID int64
20-
CommentID int64 `xorm:"INDEX"`
21-
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
22-
RefName string
23-
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
24-
Content string `xorm:"TEXT"`
25-
CreatedUnix timeutil.TimeStamp `xorm:"created"`
26-
}
27-
28-
// TableName sets the name of this table
29-
func (a *improveActionTableIndicesAction) TableName() string {
30-
return "action"
31-
}
32-
33-
// TableIndices implements xorm's TableIndices interface
34-
func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {
35-
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
36-
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
37-
38-
repoIndex := schemas.NewIndex("r_c_u_d", schemas.IndexType)
39-
repoIndex.AddColumn("repo_id", "created_unix", "user_id", "is_deleted")
40-
41-
return []*schemas.Index{actUserIndex, repoIndex}
42-
}
43-
44-
func improveActionTableIndices(x *xorm.Engine) error {
45-
return x.Sync2(&improveActionTableIndicesAction{})
46-
}
7+
// This migration added non-ideal indices to the action table which on larger datasets slowed things down
8+
// it has been superceded by v218.go

models/migrations/v218.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/modules/timeutil"
9+
10+
"xorm.io/xorm"
11+
"xorm.io/xorm/schemas"
12+
)
13+
14+
type improveActionTableIndicesAction struct {
15+
ID int64 `xorm:"pk autoincr"`
16+
UserID int64 // Receiver user id.
17+
OpType int
18+
ActUserID int64 // Action user id.
19+
RepoID int64
20+
CommentID int64 `xorm:"INDEX"`
21+
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
22+
RefName string
23+
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
24+
Content string `xorm:"TEXT"`
25+
CreatedUnix timeutil.TimeStamp `xorm:"created"`
26+
}
27+
28+
// TableName sets the name of this table
29+
func (*improveActionTableIndicesAction) TableName() string {
30+
return "action"
31+
}
32+
33+
// TableIndices implements xorm's TableIndices interface
34+
func (*improveActionTableIndicesAction) TableIndices() []*schemas.Index {
35+
repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
36+
repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
37+
38+
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
39+
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
40+
41+
return []*schemas.Index{actUserIndex, repoIndex}
42+
}
43+
44+
func improveActionTableIndices(x *xorm.Engine) error {
45+
return x.Sync2(&improveActionTableIndicesAction{})
46+
}

0 commit comments

Comments
 (0)