mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-10 05:08:08 -06:00
[feature] Filters v1 (#2594)
* Implement client-side v1 filters * Exclude linter false positives * Update test/envparsing.sh * Fix minor Swagger, style, and Bun usage issues * Regenerate Swagger * De-generify filter keywords * Remove updating filter statuses This is an operation that the Mastodon v2 filter API doesn't actually have, because filter statuses, unlike keywords, don't have options: the only info they contain is the status ID to be filtered. * Add a test for filter statuses specifically * De-generify filter statuses * Inline FilterEntry * Use vertical style for Bun operations consistently * Add comment on Filter DB interface * Remove GoLand linter control comments Our existing linters should catch these, or they don't matter very much * Reduce memory ratio for filters
This commit is contained in:
parent
7bc536d1f7
commit
61a2b91f45
50 changed files with 4672 additions and 52 deletions
|
|
@ -201,6 +201,9 @@ type CacheConfiguration struct {
|
|||
BoostOfIDsMemRatio float64 `name:"boost-of-ids-mem-ratio"`
|
||||
EmojiMemRatio float64 `name:"emoji-mem-ratio"`
|
||||
EmojiCategoryMemRatio float64 `name:"emoji-category-mem-ratio"`
|
||||
FilterMemRatio float64 `name:"filter-mem-ratio"`
|
||||
FilterKeywordMemRatio float64 `name:"filter-keyword-mem-ratio"`
|
||||
FilterStatusMemRatio float64 `name:"filter-status-mem-ratio"`
|
||||
FollowMemRatio float64 `name:"follow-mem-ratio"`
|
||||
FollowIDsMemRatio float64 `name:"follow-ids-mem-ratio"`
|
||||
FollowRequestMemRatio float64 `name:"follow-request-mem-ratio"`
|
||||
|
|
|
|||
|
|
@ -165,6 +165,9 @@ var Defaults = Configuration{
|
|||
BoostOfIDsMemRatio: 3,
|
||||
EmojiMemRatio: 3,
|
||||
EmojiCategoryMemRatio: 0.1,
|
||||
FilterMemRatio: 0.5,
|
||||
FilterKeywordMemRatio: 0.5,
|
||||
FilterStatusMemRatio: 0.5,
|
||||
FollowMemRatio: 2,
|
||||
FollowIDsMemRatio: 4,
|
||||
FollowRequestMemRatio: 2,
|
||||
|
|
|
|||
|
|
@ -2975,6 +2975,81 @@ func GetCacheEmojiCategoryMemRatio() float64 { return global.GetCacheEmojiCatego
|
|||
// SetCacheEmojiCategoryMemRatio safely sets the value for global configuration 'Cache.EmojiCategoryMemRatio' field
|
||||
func SetCacheEmojiCategoryMemRatio(v float64) { global.SetCacheEmojiCategoryMemRatio(v) }
|
||||
|
||||
// GetCacheFilterMemRatio safely fetches the Configuration value for state's 'Cache.FilterMemRatio' field
|
||||
func (st *ConfigState) GetCacheFilterMemRatio() (v float64) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.Cache.FilterMemRatio
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetCacheFilterMemRatio safely sets the Configuration value for state's 'Cache.FilterMemRatio' field
|
||||
func (st *ConfigState) SetCacheFilterMemRatio(v float64) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.Cache.FilterMemRatio = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// CacheFilterMemRatioFlag returns the flag name for the 'Cache.FilterMemRatio' field
|
||||
func CacheFilterMemRatioFlag() string { return "cache-filter-mem-ratio" }
|
||||
|
||||
// GetCacheFilterMemRatio safely fetches the value for global configuration 'Cache.FilterMemRatio' field
|
||||
func GetCacheFilterMemRatio() float64 { return global.GetCacheFilterMemRatio() }
|
||||
|
||||
// SetCacheFilterMemRatio safely sets the value for global configuration 'Cache.FilterMemRatio' field
|
||||
func SetCacheFilterMemRatio(v float64) { global.SetCacheFilterMemRatio(v) }
|
||||
|
||||
// GetCacheFilterKeywordMemRatio safely fetches the Configuration value for state's 'Cache.FilterKeywordMemRatio' field
|
||||
func (st *ConfigState) GetCacheFilterKeywordMemRatio() (v float64) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.Cache.FilterKeywordMemRatio
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetCacheFilterKeywordMemRatio safely sets the Configuration value for state's 'Cache.FilterKeywordMemRatio' field
|
||||
func (st *ConfigState) SetCacheFilterKeywordMemRatio(v float64) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.Cache.FilterKeywordMemRatio = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// CacheFilterKeywordMemRatioFlag returns the flag name for the 'Cache.FilterKeywordMemRatio' field
|
||||
func CacheFilterKeywordMemRatioFlag() string { return "cache-filter-keyword-mem-ratio" }
|
||||
|
||||
// GetCacheFilterKeywordMemRatio safely fetches the value for global configuration 'Cache.FilterKeywordMemRatio' field
|
||||
func GetCacheFilterKeywordMemRatio() float64 { return global.GetCacheFilterKeywordMemRatio() }
|
||||
|
||||
// SetCacheFilterKeywordMemRatio safely sets the value for global configuration 'Cache.FilterKeywordMemRatio' field
|
||||
func SetCacheFilterKeywordMemRatio(v float64) { global.SetCacheFilterKeywordMemRatio(v) }
|
||||
|
||||
// GetCacheFilterStatusMemRatio safely fetches the Configuration value for state's 'Cache.FilterStatusMemRatio' field
|
||||
func (st *ConfigState) GetCacheFilterStatusMemRatio() (v float64) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.Cache.FilterStatusMemRatio
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetCacheFilterStatusMemRatio safely sets the Configuration value for state's 'Cache.FilterStatusMemRatio' field
|
||||
func (st *ConfigState) SetCacheFilterStatusMemRatio(v float64) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.Cache.FilterStatusMemRatio = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// CacheFilterStatusMemRatioFlag returns the flag name for the 'Cache.FilterStatusMemRatio' field
|
||||
func CacheFilterStatusMemRatioFlag() string { return "cache-filter-status-mem-ratio" }
|
||||
|
||||
// GetCacheFilterStatusMemRatio safely fetches the value for global configuration 'Cache.FilterStatusMemRatio' field
|
||||
func GetCacheFilterStatusMemRatio() float64 { return global.GetCacheFilterStatusMemRatio() }
|
||||
|
||||
// SetCacheFilterStatusMemRatio safely sets the value for global configuration 'Cache.FilterStatusMemRatio' field
|
||||
func SetCacheFilterStatusMemRatio(v float64) { global.SetCacheFilterStatusMemRatio(v) }
|
||||
|
||||
// GetCacheFollowMemRatio safely fetches the Configuration value for state's 'Cache.FollowMemRatio' field
|
||||
func (st *ConfigState) GetCacheFollowMemRatio() (v float64) {
|
||||
st.mutex.RLock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue