trends

package
v1.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package trends provides trending content analysis and aggregation services.

Index

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"`
	Shares      int64  `json:"shares"`
}

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 (s *Service) GetStatusesByLink(ctx context.Context, url string, limit int) ([]interface{}, error)

GetStatusesByLink returns statuses that contain a specific link

func (*Service) GetTrendingHashtags

func (s *Service) GetTrendingHashtags(ctx context.Context, limit int) ([]HashtagTrend, error)

GetTrendingHashtags returns trending hashtags

func (s *Service) GetTrendingLinks(ctx context.Context, limit int) ([]LinkTrend, error)

GetTrendingLinks returns trending links

func (*Service) GetTrendingStatuses

func (s *Service) GetTrendingStatuses(ctx context.Context, limit int) ([]StatusTrend, error)

GetTrendingStatuses returns trending statuses

func (*Service) GetTrends

func (s *Service) GetTrends(ctx context.Context, limit int) ([]Trend, error)

GetTrends returns general trends (mix of all types)

func (*Service) RecordHashtagUsage

func (s *Service) RecordHashtagUsage(ctx context.Context, hashtag string, statusID string, authorID string) error

RecordHashtagUsage records hashtag usage for trending calculation

func (*Service) RecordLinkShare

func (s *Service) RecordLinkShare(ctx context.Context, url string, statusID string, authorID string) error

RecordLinkShare records link sharing for trending calculation

func (*Service) RecordStatusEngagement

func (s *Service) RecordStatusEngagement(ctx context.Context, statusID string, engagementType string, userID string) error

RecordStatusEngagement records engagement 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 Trend

type Trend struct {
	Type  string `json:"type"`
	Value any    `json:"value"`
}

Trend represents a general trend

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

type TrendScore struct {
	Item  TrendItem
	Score float64
}

TrendScore represents a calculated trend score

type TrendType

type TrendType string

TrendType represents the type of trending item

const (
	// TrendTypeHashtag represents hashtag trend type
	TrendTypeHashtag TrendType = "hashtag"
	// TrendTypeStatus represents status/post trend type
	TrendTypeStatus TrendType = "status"
	// TrendTypeLink represents link/URL trend type
	TrendTypeLink TrendType = "link"
)

type TrendingAlgorithm

type TrendingAlgorithm interface {
	Calculate(items []TrendItem) []TrendScore
}

TrendingAlgorithm defines the interface for different trending algorithms

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL