MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / PruneHistory

Method PruneHistory

auth/role.go:44–54  ·  view source on GitHub ↗
(partitionWindow time.Duration)

Source from the content-addressed store, hash-verified

42type TimedSetHistory map[string]GrantHistory
43
44func (timedSet TimedSetHistory) PruneHistory(partitionWindow time.Duration) []string {
45 prunedChannelHistory := make([]string, 0)
46 for chanName, grantHistory := range timedSet {
47 grantTime := time.Unix(grantHistory.UpdatedAt, 0)
48 if time.Since(grantTime) > partitionWindow {
49 delete(timedSet, chanName)
50 prunedChannelHistory = append(prunedChannelHistory, chanName)
51 }
52 }
53 return prunedChannelHistory
54}
55
56type GrantHistory struct {
57 UpdatedAt int64 `json:"updated_at"` // Timestamp at which history was last updated, allows for pruning

Callers 1

calculateHistoryMethod · 0.80

Calls 1

SinceMethod · 0.45

Tested by

no test coverage detected