mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 18:12:25 -05:00
finish writing more code comments
This commit is contained in:
parent
f715bec563
commit
e99d0d7276
1 changed files with 21 additions and 3 deletions
24
internal/cache/timeline/status.go
vendored
24
internal/cache/timeline/status.go
vendored
|
|
@ -261,21 +261,39 @@ type StatusTimeline struct {
|
||||||
// a sliding average. a problem for future kim!
|
// a sliding average. a problem for future kim!
|
||||||
last atomic.Pointer[structr.Direction]
|
last atomic.Pointer[structr.Direction]
|
||||||
|
|
||||||
// ...
|
// defines the 'maximum' count of
|
||||||
|
// entries in the timeline that we
|
||||||
|
// apply our Trim() operation
|
||||||
|
// threshold to. the timeline itself
|
||||||
|
// does not limit items due to absurd
|
||||||
|
// complexities it would introduce,
|
||||||
|
// so we we apply a 'cut-off' via
|
||||||
|
// regular calls to Trim(threshold).
|
||||||
max int
|
max int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init ...
|
// Init will initialize the timeline for usage,
|
||||||
|
// by preparing internal indices etc. This also
|
||||||
|
// sets the given max capacity for Trim() operations.
|
||||||
func (t *StatusTimeline) Init(cap int) {
|
func (t *StatusTimeline) Init(cap int) {
|
||||||
t.cache.Init(structr.TimelineConfig[*StatusMeta, string]{
|
t.cache.Init(structr.TimelineConfig[*StatusMeta, string]{
|
||||||
|
|
||||||
|
// Timeline item primary key field.
|
||||||
PKey: structr.IndexConfig{Fields: "ID"},
|
PKey: structr.IndexConfig{Fields: "ID"},
|
||||||
|
|
||||||
|
// Additional indexed fields.
|
||||||
Indices: []structr.IndexConfig{
|
Indices: []structr.IndexConfig{
|
||||||
{Fields: "AccountID", Multiple: true},
|
{Fields: "AccountID", Multiple: true},
|
||||||
{Fields: "BoostOfID", Multiple: false},
|
|
||||||
{Fields: "BoostOfAccountID", Multiple: true},
|
{Fields: "BoostOfAccountID", Multiple: true},
|
||||||
|
|
||||||
|
// By setting multiple=false for BoostOfID, this will prevent
|
||||||
|
// timeline entries with matching BoostOfID will not be inserted
|
||||||
|
// after the first, which allows us to prevent repeated boosts
|
||||||
|
// of the same status from showing up within 'cap' entries.
|
||||||
|
{Fields: "BoostOfID", Multiple: false},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Timeline item copy function.
|
||||||
Copy: func(s *StatusMeta) *StatusMeta {
|
Copy: func(s *StatusMeta) *StatusMeta {
|
||||||
var prepared *apimodel.Status
|
var prepared *apimodel.Status
|
||||||
if s.prepared != nil {
|
if s.prepared != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue