mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Implement following hashtags (#3141)
* Implement followed tags API * Insert statuses with followed tags into home timelines * Test following and unfollowing tags * Correct Swagger path params * Trim conversation caches * Migration for followed_tags table * Followed tag caches and DB implementation * Lint and tests * Add missing tag info endpoint, reorganize tag API * Unwrap boosts when timelining based on tags * Apply visibility filters to tag followers * Address review comments
This commit is contained in:
28
internal/cache/db.go
vendored
28
internal/cache/db.go
vendored
@ -29,6 +29,9 @@ type DBCaches struct {
|
||||
// Account provides access to the gtsmodel Account database cache.
|
||||
Account StructCache[*gtsmodel.Account]
|
||||
|
||||
// AccountIDsFollowingTag caches account IDs following a given tag ID.
|
||||
AccountIDsFollowingTag SliceCache[string]
|
||||
|
||||
// AccountNote provides access to the gtsmodel Note database cache.
|
||||
AccountNote StructCache[*gtsmodel.AccountNote]
|
||||
|
||||
@ -160,6 +163,9 @@ type DBCaches struct {
|
||||
// Tag provides access to the gtsmodel Tag database cache.
|
||||
Tag StructCache[*gtsmodel.Tag]
|
||||
|
||||
// TagIDsFollowedByAccount caches tag IDs followed by a given account ID.
|
||||
TagIDsFollowedByAccount SliceCache[string]
|
||||
|
||||
// ThreadMute provides access to the gtsmodel ThreadMute database cache.
|
||||
ThreadMute StructCache[*gtsmodel.ThreadMute]
|
||||
|
||||
@ -234,6 +240,17 @@ func (c *Caches) initAccount() {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initAccountIDsFollowingTag() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateSliceCacheMax(
|
||||
config.GetCacheAccountIDsFollowingTagMemRatio(),
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
c.DB.AccountIDsFollowingTag.Init(0, cap)
|
||||
}
|
||||
|
||||
func (c *Caches) initAccountNote() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
@ -1317,6 +1334,17 @@ func (c *Caches) initTag() {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initTagIDsFollowedByAccount() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateSliceCacheMax(
|
||||
config.GetCacheTagIDsFollowedByAccountMemRatio(),
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
c.DB.TagIDsFollowedByAccount.Init(0, cap)
|
||||
}
|
||||
|
||||
func (c *Caches) initThreadMute() {
|
||||
cap := calculateResultCacheMax(
|
||||
sizeofThreadMute(), // model in-mem size.
|
||||
|
Reference in New Issue
Block a user