summaryrefslogtreecommitdiff
path: root/testrig/testmodels.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-06-24 17:24:34 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-06-24 17:24:34 +0200
commit996da6e0291b158093d917ca76933584f464d668 (patch)
tree38c12b20f76076f08ef5c8b8715ba3d8629fa0fb /testrig/testmodels.go
parent[bugfix] update the default configuration to not set a db type or address, to... (diff)
downloadgotosocial-996da6e0291b158093d917ca76933584f464d668.tar.xz
[performance] filter model and database table improvements (#4277)
- removes unnecessary fields / columns (created_at, updated_at) - replaces filter.context_* columns with singular filter.contexts bit field which should save both struct memory and database space - replaces filter.action string with integer enum type which should save both struct memory and database space - adds links from filter to filter_* tables with Filter{}.KeywordIDs and Filter{}.StatusIDs fields (this also means we now have those ID slices cached, which reduces some lookups) - removes account_id fields from filter_* tables, since there's a more direct connection between filter and filter_* tables, and filter.account_id already exists - refactors a bunch of the filter processor logic to save on code repetition, factor in the above changes, fix a few bugs with missed error returns and bring it more in-line with some of our newer code Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4277 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r--testrig/testmodels.go104
1 files changed, 37 insertions, 67 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go
index 42caf59bd..d8cfb9b82 100644
--- a/testrig/testmodels.go
+++ b/testrig/testmodels.go
@@ -4091,54 +4091,45 @@ func NewTestDereferenceRequests(accounts map[string]*gtsmodel.Account) map[strin
func NewTestFilters() map[string]*gtsmodel.Filter {
return map[string]*gtsmodel.Filter{
"local_account_1_filter_1": {
- ID: "01HN26VM6KZTW1ANNRVSBMA461",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
- Title: "fnord",
- Action: gtsmodel.FilterActionWarn,
- ContextHome: util.Ptr(true),
- ContextPublic: util.Ptr(true),
+ ID: "01HN26VM6KZTW1ANNRVSBMA461",
+ AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
+ Title: "fnord",
+ Action: gtsmodel.FilterActionWarn,
+ Contexts: gtsmodel.FilterContexts(gtsmodel.FilterContextHome | gtsmodel.FilterContextPublic),
+ KeywordIDs: []string{"01HN272TAVWAXX72ZX4M8JZ0PS"},
},
"local_account_1_filter_2": {
- ID: "01HN277FSPQAWXZXK92QPPYF79",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
- Title: "metasyntactic variables",
- Action: gtsmodel.FilterActionWarn,
- ContextHome: util.Ptr(true),
- ContextPublic: util.Ptr(true),
+ ID: "01HN277FSPQAWXZXK92QPPYF79",
+ AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
+ Title: "metasyntactic variables",
+ Action: gtsmodel.FilterActionWarn,
+ Contexts: gtsmodel.FilterContexts(gtsmodel.FilterContextHome | gtsmodel.FilterContextPublic),
+ KeywordIDs: []string{"01HN277Y11ENG4EC1ERMAC9FH4", "01HN278494N88BA2FY4DZ5JTNS", "01HXATJTGYT4BTG2YASE5M7GSD"},
},
"local_account_1_filter_3": {
- ID: "01HWXQDXE4QX4R9EGMG729Y76C",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
- Title: "puppies",
- Action: gtsmodel.FilterActionWarn,
- ContextHome: util.Ptr(true),
- ContextPublic: util.Ptr(true),
+ ID: "01HWXQDXE4QX4R9EGMG729Y76C",
+ AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
+ Title: "puppies",
+ Action: gtsmodel.FilterActionWarn,
+ Contexts: gtsmodel.FilterContexts(gtsmodel.FilterContextHome | gtsmodel.FilterContextPublic),
+ StatusIDs: []string{"01HWXQDY8EE182AWQKS45JV50W"},
},
"local_account_1_filter_4": {
- ID: "01HZ55WWWP82WYP2A1BKWK8Y9Q",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
- Title: "empty filter with no keywords or statuses",
- Action: gtsmodel.FilterActionWarn,
- ContextHome: util.Ptr(true),
- ContextPublic: util.Ptr(true),
+ ID: "01HZ55WWWP82WYP2A1BKWK8Y9Q",
+ AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
+ Title: "empty filter with no keywords or statuses",
+ Action: gtsmodel.FilterActionWarn,
+ Contexts: gtsmodel.FilterContexts(gtsmodel.FilterContextHome | gtsmodel.FilterContextPublic),
+ KeywordIDs: []string{},
},
"local_account_2_filter_1": {
- ID: "01HNGFYJBED9FS0VWRVMY4TKXH",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1VYJAE00TVVGMM5JNJ8X",
- Title: "gamer words",
- Action: gtsmodel.FilterActionWarn,
- ContextHome: util.Ptr(true),
- ContextPublic: util.Ptr(true),
+ ID: "01HNGFYJBED9FS0VWRVMY4TKXH",
+ AccountID: "01F8MH1VYJAE00TVVGMM5JNJ8X",
+ Title: "gamer words",
+ Action: gtsmodel.FilterActionWarn,
+ Contexts: gtsmodel.FilterContexts(gtsmodel.FilterContextHome | gtsmodel.FilterContextPublic),
+ KeywordIDs: []string{"01HNGG51HV2JT67XQ5MQ7RA1WE"},
+ StatusIDs: []string{"01HX9WXVEH05E78ABR81FZFFFY"},
},
}
}
@@ -4147,45 +4138,30 @@ func NewTestFilterKeywords() map[string]*gtsmodel.FilterKeyword {
return map[string]*gtsmodel.FilterKeyword{
"local_account_1_filter_1_keyword_1": {
ID: "01HN272TAVWAXX72ZX4M8JZ0PS",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
FilterID: "01HN26VM6KZTW1ANNRVSBMA461",
Keyword: "fnord",
WholeWord: util.Ptr(true),
},
"local_account_1_filter_2_keyword_1": {
ID: "01HN277Y11ENG4EC1ERMAC9FH4",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
FilterID: "01HN277FSPQAWXZXK92QPPYF79",
Keyword: "foo",
WholeWord: util.Ptr(true),
},
"local_account_1_filter_2_keyword_2": {
ID: "01HN278494N88BA2FY4DZ5JTNS",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
FilterID: "01HN277FSPQAWXZXK92QPPYF79",
Keyword: "bar",
WholeWord: util.Ptr(true),
},
"local_account_1_filter_2_keyword_3": {
ID: "01HXATJTGYT4BTG2YASE5M7GSD",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
FilterID: "01HN277FSPQAWXZXK92QPPYF79",
Keyword: "quux",
WholeWord: util.Ptr(true),
},
"local_account_2_filter_1_keyword_1": {
ID: "01HNGG51HV2JT67XQ5MQ7RA1WE",
- CreatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- UpdatedAt: TimeMustParse("2024-01-25T12:20:03+02:00"),
- AccountID: "01F8MH1VYJAE00TVVGMM5JNJ8X",
FilterID: "01HNGFYJBED9FS0VWRVMY4TKXH",
Keyword: "Virtual Boy",
WholeWord: util.Ptr(true),
@@ -4196,20 +4172,14 @@ func NewTestFilterKeywords() map[string]*gtsmodel.FilterKeyword {
func NewTestFilterStatuses() map[string]*gtsmodel.FilterStatus {
return map[string]*gtsmodel.FilterStatus{
"local_account_1_filter_3_status_1": {
- ID: "01HWXQDY8EE182AWQKS45JV50W",
- CreatedAt: time.Time{},
- UpdatedAt: time.Time{},
- AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
- FilterID: "01HWXQDXE4QX4R9EGMG729Y76C",
- StatusID: "01F8MHAAY43M6RJ473VQFCVH37",
+ ID: "01HWXQDY8EE182AWQKS45JV50W",
+ FilterID: "01HWXQDXE4QX4R9EGMG729Y76C",
+ StatusID: "01F8MHAAY43M6RJ473VQFCVH37",
},
"local_account_2_filter_1_status_1": {
- ID: "01HX9WXVEH05E78ABR81FZFFFY",
- CreatedAt: time.Time{},
- UpdatedAt: time.Time{},
- AccountID: "01F8MH1VYJAE00TVVGMM5JNJ8X",
- FilterID: "01HNGFYJBED9FS0VWRVMY4TKXH",
- StatusID: "01FVW7JHQFSFK166WWKR8CBA6M",
+ ID: "01HX9WXVEH05E78ABR81FZFFFY",
+ FilterID: "01HNGFYJBED9FS0VWRVMY4TKXH",
+ StatusID: "01FVW7JHQFSFK166WWKR8CBA6M",
},
}
}