Documentation
¶
Overview ¶
Package trends provides trending content analysis and aggregation services.
Index ¶
- type DefaultAlgorithm
- type HashtagTrend
- type LinkTrend
- type Service
- func (s *Service) GetStatusesByLink(ctx context.Context, url string, limit int) ([]interface{}, error)
- func (s *Service) GetTrendingHashtags(ctx context.Context, limit int) ([]HashtagTrend, error)
- func (s *Service) GetTrendingLinks(ctx context.Context, limit int) ([]LinkTrend, error)
- func (s *Service) GetTrendingStatuses(ctx context.Context, limit int) ([]StatusTrend, error)
- func (s *Service) GetTrends(ctx context.Context, limit int) ([]Trend, error)
- func (s *Service) RecordHashtagUsage(ctx context.Context, hashtag string, statusID string, authorID string) error
- func (s *Service) RecordLinkShare(ctx context.Context, url string, statusID string, authorID string) error
- func (s *Service) RecordStatusEngagement(ctx context.Context, statusID string, engagementType string, userID string) error
- type StatusTrend
- type Trend
- type TrendItem
- type TrendScore
- type TrendType
- type TrendingAlgorithm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultAlgorithm ¶
type DefaultAlgorithm struct {
// contains filtered or unexported fields
}
DefaultAlgorithm implements a time-decay algorithm for trending
func NewDefaultAlgorithm ¶
func NewDefaultAlgorithm() *DefaultAlgorithm
NewDefaultAlgorithm creates the default trending algorithm
func (*DefaultAlgorithm) Calculate ¶
func (a *DefaultAlgorithm) Calculate(items []TrendItem) []TrendScore
Calculate implements TrendingAlgorithm
type HashtagTrend ¶
type HashtagTrend struct {
Name string `json:"name"`
URL string `json:"url"`
History []int64 `json:"history"` // Usage count per day for last 7 days
Uses int64 `json:"uses"` // Total uses in time period
Accounts int64 `json:"accounts"` // Unique accounts using it
}
HashtagTrend represents a trending hashtag
type LinkTrend ¶
type LinkTrend struct {
URL string `json:"url"`
Title string `json:"title"`
Description string `json:"description"`
Type string `json:"type"` // link, photo, video
AuthorName string `json:"author_name"`
Image string `json:"image"`
}
LinkTrend represents a trending link
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides trending functionality
func NewService ¶
func NewService(storage core.RepositoryStorage) *Service
NewService creates a new trending service
func (*Service) GetStatusesByLink ¶
func (s *Service) GetStatusesByLink(ctx context.Context, url string, limit int) ([]interface{}, error)
GetStatusesByLink returns statuses that contain a specific link
func (*Service) GetTrendingHashtags ¶
GetTrendingHashtags returns trending hashtags
func (*Service) GetTrendingLinks ¶
GetTrendingLinks returns trending links
func (*Service) GetTrendingStatuses ¶
GetTrendingStatuses returns trending statuses
func (*Service) RecordHashtagUsage ¶
func (s *Service) RecordHashtagUsage(ctx context.Context, hashtag string, statusID string, authorID string) error
RecordHashtagUsage records hashtag usage for trending calculation
type StatusTrend ¶
type StatusTrend struct {
StatusID string `json:"id"`
URL string `json:"url"`
AuthorID string `json:"author_id"`
Content string `json:"content"`
Engagements int64 `json:"engagements"`
PublishedAt time.Time `json:"published_at"`
}
StatusTrend represents a trending status
type TrendItem ¶
type TrendItem struct {
ID string
Type TrendType
Content string
UsageCount int64
UniqueUsers int64
LastUsed time.Time
FirstSeen time.Time
Engagements int64 // likes, boosts, replies
TrustScore float64 // average trust score of users interacting
}
TrendItem represents an item that can trend (hashtag, status, link)
type TrendScore ¶
TrendScore represents a calculated trend score
type TrendingAlgorithm ¶
type TrendingAlgorithm interface {
Calculate(items []TrendItem) []TrendScore
}
TrendingAlgorithm defines the interface for different trending algorithms