mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 23:22:25 -05:00
[performance] Speed up some of the slower db queries (#523)
* remove unnecessary LOWER() db calls * warn during slow db queries * use bundb built-in exists function * add db block test * update account block query * add domain block db test * optimize domain block query * fix implementing wrong test * exclude most columns when checking block * go fmt * remote more unnecessary use of LOWER()
This commit is contained in:
parent
faae2505c0
commit
a5852fd7e4
13 changed files with 151 additions and 29 deletions
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
)
|
||||
|
||||
type RelationshipTestSuite struct {
|
||||
|
|
@ -32,7 +33,45 @@ type RelationshipTestSuite struct {
|
|||
}
|
||||
|
||||
func (suite *RelationshipTestSuite) TestIsBlocked() {
|
||||
suite.Suite.T().Skip("TODO: implement")
|
||||
ctx := context.Background()
|
||||
|
||||
account1 := suite.testAccounts["local_account_1"].ID
|
||||
account2 := suite.testAccounts["local_account_2"].ID
|
||||
|
||||
// no blocks exist between account 1 and account 2
|
||||
blocked, err := suite.db.IsBlocked(ctx, account1, account2, false)
|
||||
suite.NoError(err)
|
||||
suite.False(blocked)
|
||||
|
||||
blocked, err = suite.db.IsBlocked(ctx, account2, account1, false)
|
||||
suite.NoError(err)
|
||||
suite.False(blocked)
|
||||
|
||||
// have account1 block account2
|
||||
suite.db.Put(ctx, >smodel.Block{
|
||||
ID: "01G202BCSXXJZ70BHB5KCAHH8C",
|
||||
URI: "http://localhost:8080/some_block_uri_1",
|
||||
AccountID: account1,
|
||||
TargetAccountID: account2,
|
||||
})
|
||||
|
||||
// account 1 now blocks account 2
|
||||
blocked, err = suite.db.IsBlocked(ctx, account1, account2, false)
|
||||
suite.NoError(err)
|
||||
suite.True(blocked)
|
||||
|
||||
// account 2 doesn't block account 1
|
||||
blocked, err = suite.db.IsBlocked(ctx, account2, account1, false)
|
||||
suite.NoError(err)
|
||||
suite.False(blocked)
|
||||
|
||||
// a block exists in either direction between the two
|
||||
blocked, err = suite.db.IsBlocked(ctx, account1, account2, true)
|
||||
suite.NoError(err)
|
||||
suite.True(blocked)
|
||||
blocked, err = suite.db.IsBlocked(ctx, account2, account1, true)
|
||||
suite.NoError(err)
|
||||
suite.True(blocked)
|
||||
}
|
||||
|
||||
func (suite *RelationshipTestSuite) TestGetBlock() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue