storage

package
v0.0.0-...-9213475 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("record not found")
	ErrAlreadyExists = errors.New("record already exists")
	ErrInvalidInput  = errors.New("invalid input")
	ErrUnauthorized  = errors.New("unauthorized")
)

Common errors

Functions

This section is empty.

Types

type AnalyticsEvent

type AnalyticsEvent struct {
	Type      string                 `json:"type"`
	UserID    *uuid.UUID             `json:"user_id,omitempty"`
	StoryID   *uuid.UUID             `json:"story_id,omitempty"`
	Timestamp int64                  `json:"timestamp"`
	Data      map[string]interface{} `json:"data,omitempty"`
}

Analytics types

type AnalyticsStore

type AnalyticsStore interface {
	RecordEvent(ctx context.Context, event AnalyticsEvent) error
	GetUserMetrics(ctx context.Context, userID uuid.UUID, period string) (*UserMetrics, error)
	GetStoryMetrics(ctx context.Context, storyID uuid.UUID, period string) (*StoryMetrics, error)
	GetPlatformMetrics(ctx context.Context, period string) (*PlatformMetrics, error)
	GetTopStories(ctx context.Context, period string, limit int) ([]*TopStoryMetric, error)
	GetTopUsers(ctx context.Context, period string, limit int) ([]*TopUserMetric, error)
	GetEngagementMetrics(ctx context.Context, period string) (*EngagementMetrics, error)
}

AnalyticsStore defines the interface for analytics storage operations

type BatchOperation

type BatchOperation struct {
	Operation string      `json:"operation"`
	Data      interface{} `json:"data"`
}

Batch operations

type BatchResult

type BatchResult struct {
	Success []uuid.UUID `json:"success"`
	Failed  []uuid.UUID `json:"failed"`
	Errors  []string    `json:"errors"`
}

type CacheStore

type CacheStore interface {
	Set(ctx context.Context, key string, value interface{}, expiration int) error
	Get(ctx context.Context, key string, dest interface{}) error
	Delete(ctx context.Context, key string) error
	Exists(ctx context.Context, key string) (bool, error)
	SetMany(ctx context.Context, items map[string]interface{}, expiration int) error
	GetMany(ctx context.Context, keys []string) (map[string]interface{}, error)
	DeleteMany(ctx context.Context, keys []string) error
	Increment(ctx context.Context, key string, value int64) (int64, error)
	Decrement(ctx context.Context, key string, value int64) (int64, error)
	Expire(ctx context.Context, key string, expiration int) error
	TTL(ctx context.Context, key string) (int, error)
	FlushAll(ctx context.Context) error
}

CacheStore defines the interface for caching operations

type EngagementMetrics

type EngagementMetrics struct {
	AverageViewsPerStory     float64 `json:"average_views_per_story"`
	AverageReactionsPerStory float64 `json:"average_reactions_per_story"`
	ViewToReactionRatio      float64 `json:"view_to_reaction_ratio"`
	DailyActiveUsers         int     `json:"daily_active_users"`
	RetentionRate            float64 `json:"retention_rate"`
}

type FollowStore

type FollowStore interface {
	Create(ctx context.Context, follow *models.Follow) error
	Delete(ctx context.Context, id uuid.UUID) error
	DeleteByUsers(ctx context.Context, followerID, followeeID uuid.UUID) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.Follow, error)
	GetFollowers(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.FollowWithUser, error)
	GetFollowing(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.FollowWithUser, error)
	IsFollowing(ctx context.Context, followerID, followeeID uuid.UUID) (bool, error)
	GetFollowStats(ctx context.Context, userID uuid.UUID) (*models.FollowStats, error)
	GetMutualFollows(ctx context.Context, userID1, userID2 uuid.UUID) (*models.MutualFollowCheck, error)
	GetFollowSuggestions(ctx context.Context, userID uuid.UUID, limit int) ([]*models.FollowSuggestion, error)
}

FollowStore defines the interface for follow relationship storage operations

func NewFollowStore

func NewFollowStore(db *sqlx.DB, redisClient *RedisClient, logger *zap.Logger) FollowStore

NewFollowStore creates a new follow store

type FollowStoreImpl

type FollowStoreImpl struct {
	// contains filtered or unexported fields
}

FollowStoreImpl implements FollowStore interface

func (*FollowStoreImpl) Create

func (s *FollowStoreImpl) Create(ctx context.Context, follow *models.Follow) error

Create creates a new follow relationship

func (*FollowStoreImpl) Delete

func (s *FollowStoreImpl) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a follow relationship by ID - ADDED MISSING METHOD

func (*FollowStoreImpl) DeleteByUsers

func (s *FollowStoreImpl) DeleteByUsers(ctx context.Context, followerID, followeeID uuid.UUID) error

DeleteByUsers deletes follow relationship by user IDs

func (*FollowStoreImpl) GetByID

func (s *FollowStoreImpl) GetByID(ctx context.Context, id uuid.UUID) (*models.Follow, error)

GetByID gets a follow relationship by ID - ADDED MISSING METHOD

func (*FollowStoreImpl) GetFollowStats

func (s *FollowStoreImpl) GetFollowStats(ctx context.Context, userID uuid.UUID) (*models.FollowStats, error)

GetFollowStats gets follow statistics for a user - ADDED MISSING METHOD

func (*FollowStoreImpl) GetFollowSuggestions

func (s *FollowStoreImpl) GetFollowSuggestions(ctx context.Context, userID uuid.UUID, limit int) ([]*models.FollowSuggestion, error)

GetFollowSuggestions gets follow suggestions for a user - ADDED MISSING METHOD

func (*FollowStoreImpl) GetFollowers

func (s *FollowStoreImpl) GetFollowers(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.FollowWithUser, error)

GetFollowers gets followers for a user

func (*FollowStoreImpl) GetFollowing

func (s *FollowStoreImpl) GetFollowing(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.FollowWithUser, error)

GetFollowing gets users that a user is following

func (*FollowStoreImpl) GetMutualFollows

func (s *FollowStoreImpl) GetMutualFollows(ctx context.Context, userID1, userID2 uuid.UUID) (*models.MutualFollowCheck, error)

GetMutualFollows gets mutual follow status between two users - ADDED MISSING METHOD

func (*FollowStoreImpl) IsFollowing

func (s *FollowStoreImpl) IsFollowing(ctx context.Context, followerID, followeeID uuid.UUID) (bool, error)

IsFollowing checks if user A follows user B

type HealthChecker

type HealthChecker interface {
	HealthCheck(ctx context.Context) error
}

Health check interface

type PaginatedResult

type PaginatedResult struct {
	Data       interface{} `json:"data"`
	Total      int         `json:"total"`
	Limit      int         `json:"limit"`
	Offset     int         `json:"offset"`
	HasMore    bool        `json:"has_more"`
	NextOffset *int        `json:"next_offset,omitempty"`
}

Paginated results

type PlatformMetrics

type PlatformMetrics struct {
	ActiveUsers    int `json:"active_users"`
	StoriesPosted  int `json:"stories_posted"`
	TotalViews     int `json:"total_views"`
	TotalReactions int `json:"total_reactions"`
}

type PostgresDB

type PostgresDB struct {
	// contains filtered or unexported fields
}

PostgresDB wraps the database connection

func NewPostgresDB

func NewPostgresDB(cfg *config.Config, logger *zap.Logger) (*PostgresDB, error)

NewPostgresDB creates a new PostgreSQL database connection

func (*PostgresDB) Close

func (p *PostgresDB) Close() error

Close closes the database connection

func (*PostgresDB) DB

func (p *PostgresDB) DB() *sqlx.DB

DB returns the underlying database connection

func (*PostgresDB) GetStats

func (p *PostgresDB) GetStats() SqlDbStats

GetStats returns database connection statistics

func (*PostgresDB) Health

func (p *PostgresDB) Health(ctx context.Context) error

Health checks the database connection health

func (*PostgresDB) Migrate

func (p *PostgresDB) Migrate(ctx context.Context, migrationDir string) error

Migrate runs database migrations

func (*PostgresDB) WithTransaction

func (p *PostgresDB) WithTransaction(ctx context.Context, fn func(*sqlx.Tx) error) error

WithTransaction executes a function within a database transaction

type ReactionStore

type ReactionStore interface {
	Create(ctx context.Context, reaction *models.Reaction) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.Reaction, error)
	GetByStoryID(ctx context.Context, storyID uuid.UUID, limit, offset int) ([]*models.ReactionWithUser, error)
	GetByUserID(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.Reaction, error)
	Update(ctx context.Context, reaction *models.Reaction) error
	Delete(ctx context.Context, id uuid.UUID) error
	GetUserReactionForStory(ctx context.Context, storyID, userID uuid.UUID) (*models.Reaction, error)
	GetReactionSummary(ctx context.Context, storyID uuid.UUID) (*models.ReactionSummary, error)
	GetReactionStats(ctx context.Context, storyID uuid.UUID) (map[models.ReactionType]int, error)
}

ReactionStore defines the interface for reaction storage operations

func NewReactionStore

func NewReactionStore(db *sqlx.DB, redisClient *RedisClient, logger *zap.Logger) ReactionStore

NewReactionStore creates a new reaction store

type ReactionStoreImpl

type ReactionStoreImpl struct {
	// contains filtered or unexported fields
}

ReactionStoreImpl implements ReactionStore interface

func (*ReactionStoreImpl) Create

func (s *ReactionStoreImpl) Create(ctx context.Context, reaction *models.Reaction) error

Create creates a new reaction

func (*ReactionStoreImpl) Delete

func (s *ReactionStoreImpl) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a reaction

func (*ReactionStoreImpl) GetByID

func (s *ReactionStoreImpl) GetByID(ctx context.Context, id uuid.UUID) (*models.Reaction, error)

GetByID gets a reaction by ID

func (*ReactionStoreImpl) GetByStoryID

func (s *ReactionStoreImpl) GetByStoryID(ctx context.Context, storyID uuid.UUID, limit, offset int) ([]*models.ReactionWithUser, error)

GetByStoryID gets reactions for a specific story

func (*ReactionStoreImpl) GetByUserID

func (s *ReactionStoreImpl) GetByUserID(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.Reaction, error)

GetByUserID gets reactions by a specific user

func (*ReactionStoreImpl) GetReactionStats

func (s *ReactionStoreImpl) GetReactionStats(ctx context.Context, storyID uuid.UUID) (map[models.ReactionType]int, error)

GetReactionStats gets reaction statistics for a story

func (*ReactionStoreImpl) GetReactionSummary

func (s *ReactionStoreImpl) GetReactionSummary(ctx context.Context, storyID uuid.UUID) (*models.ReactionSummary, error)

GetReactionSummary gets a summary of reactions for a story

func (*ReactionStoreImpl) GetUserReactionForStory

func (s *ReactionStoreImpl) GetUserReactionForStory(ctx context.Context, storyID, userID uuid.UUID) (*models.Reaction, error)

GetUserReactionForStory gets a user's reaction for a specific story

func (*ReactionStoreImpl) Update

func (s *ReactionStoreImpl) Update(ctx context.Context, reaction *models.Reaction) error

Update updates a reaction

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

RedisClient wraps redis client with additional functionality

func NewRedisClient

func NewRedisClient(cfg *config.Config, logger *zap.Logger) (*RedisClient, error)

NewRedisClient creates a new Redis client

func (*RedisClient) Close

func (r *RedisClient) Close() error

Close closes the Redis connection

func (*RedisClient) Decrement

func (r *RedisClient) Decrement(ctx context.Context, key string, value int64) (int64, error)

Decrement decrements a key's value

func (*RedisClient) Delete

func (r *RedisClient) Delete(ctx context.Context, key string) error

Delete removes a key from Redis

func (*RedisClient) DeleteMany

func (r *RedisClient) DeleteMany(ctx context.Context, keys []string) error

DeleteMany deletes multiple keys

func (*RedisClient) Eval

func (r *RedisClient) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd

Eval executes a Lua script

func (*RedisClient) EvalSha

func (r *RedisClient) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd

EvalSha executes a Lua script by SHA

func (*RedisClient) Exists

func (r *RedisClient) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in Redis

func (*RedisClient) Expire

func (r *RedisClient) Expire(ctx context.Context, key string, expiration int) error

Expire sets expiration for a key

func (*RedisClient) FlushAll

func (r *RedisClient) FlushAll(ctx context.Context) error

FlushAll flushes all keys

func (*RedisClient) Get

func (r *RedisClient) Get(ctx context.Context, key string, dest interface{}) error

Get retrieves a value from Redis

func (*RedisClient) GetClient

func (r *RedisClient) GetClient() *redis.Client

GetClient returns the underlying Redis client

func (*RedisClient) GetMany

func (r *RedisClient) GetMany(ctx context.Context, keys []string) (map[string]interface{}, error)

GetMany gets multiple keys

func (*RedisClient) Health

func (r *RedisClient) Health(ctx context.Context) error

Health checks Redis connection health

func (*RedisClient) Increment

func (r *RedisClient) Increment(ctx context.Context, key string, value int64) (int64, error)

Increment increments a key's value

func (*RedisClient) Info

func (r *RedisClient) Info(ctx context.Context, section ...string) *redis.StringCmd

Info gets Redis server information

func (*RedisClient) Ping

func (r *RedisClient) Ping(ctx context.Context) *redis.StatusCmd

Ping tests connectivity to Redis

func (*RedisClient) Pipeline

func (r *RedisClient) Pipeline() redis.Pipeliner

Pipeline operations for batch processing

func (*RedisClient) ScriptExists

func (r *RedisClient) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd

ScriptExists checks if scripts exist

func (*RedisClient) ScriptFlush

func (r *RedisClient) ScriptFlush(ctx context.Context) *redis.StatusCmd

ScriptFlush flushes all scripts

func (*RedisClient) ScriptKill

func (r *RedisClient) ScriptKill(ctx context.Context) *redis.StatusCmd

ScriptKill kills a running script

func (*RedisClient) ScriptLoad

func (r *RedisClient) ScriptLoad(ctx context.Context, script string) *redis.StringCmd

ScriptLoad loads a script

func (*RedisClient) Set

func (r *RedisClient) Set(ctx context.Context, key string, value interface{}, expiration int) error

Set stores a value in Redis with expiration

func (*RedisClient) SetMany

func (r *RedisClient) SetMany(ctx context.Context, items map[string]interface{}, expiration int) error

SetMany sets multiple key-value pairs

func (*RedisClient) TTL

func (r *RedisClient) TTL(ctx context.Context, key string) (int, error)

TTL gets the time to live for a key

type SearchFilters

type SearchFilters struct {
	Query     string            `json:"query"`
	Filters   map[string]string `json:"filters"`
	SortBy    string            `json:"sort_by"`
	SortOrder string            `json:"sort_order"`
	Limit     int               `json:"limit"`
	Offset    int               `json:"offset"`
}

Search filters

type SessionStore

type SessionStore interface {
	Create(ctx context.Context, session *models.Session) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.Session, error)
	GetByTokenID(ctx context.Context, tokenID string) (*models.Session, error)
	GetByUserID(ctx context.Context, userID uuid.UUID) ([]*models.Session, error)
	Update(ctx context.Context, session *models.Session) error
	Delete(ctx context.Context, id uuid.UUID) error
	DeleteExpired(ctx context.Context) error
	DeleteByUserID(ctx context.Context, userID uuid.UUID) error
	IsValidSession(ctx context.Context, tokenID string) (bool, error)
}

SessionStore defines the interface for session storage operations

type SqlDbStats

type SqlDbStats struct {
	OpenConnections   int
	InUse             int
	Idle              int
	WaitCount         int64
	WaitDuration      time.Duration
	MaxIdleClosed     int64
	MaxIdleTimeClosed int64
	MaxLifetimeClosed int64
}

SqlDbStats represents database connection statistics

type StoreFactory

type StoreFactory interface {
	NewUserStore() UserStore
	NewStoryStore() StoryStore
	NewFollowStore() FollowStore
	NewViewStore() ViewStore
	NewReactionStore() ReactionStore
	NewSessionStore() SessionStore
	NewAnalyticsStore() AnalyticsStore
	Close() error
}

Store factory interface

type StoryMetrics

type StoryMetrics struct {
	StoryID     uuid.UUID `json:"story_id"`
	Views       int       `json:"views"`
	UniqueViews int       `json:"unique_views"`
	Reactions   int       `json:"reactions"`
	Shares      int       `json:"shares"`
}

type StoryStore

type StoryStore interface {
	Create(ctx context.Context, story *models.Story) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.Story, error)
	GetByAuthorID(ctx context.Context, authorID uuid.UUID, limit, offset int) ([]*models.Story, error)
	GetFeed(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.Story, error)
	GetPublic(ctx context.Context, limit, offset int) ([]*models.Story, error)
	Update(ctx context.Context, story *models.Story) error
	Delete(ctx context.Context, id uuid.UUID) error
	GetExpired(ctx context.Context, limit, offset int) ([]*models.Story, error)
	IncrementViewCount(ctx context.Context, storyID uuid.UUID) error
	GetViewCount(ctx context.Context, storyID uuid.UUID) (int, error)
}

StoryStore defines the interface for story storage operations

func NewStoryStore

func NewStoryStore(db *sqlx.DB, redisClient *RedisClient, logger *zap.Logger) StoryStore

NewStoryStore creates a new story store

type StoryStoreImpl

type StoryStoreImpl struct {
	// contains filtered or unexported fields
}

StoryStoreImpl implements StoryStore interface

func (*StoryStoreImpl) Create

func (s *StoryStoreImpl) Create(ctx context.Context, story *models.Story) error

Create creates a new story

func (*StoryStoreImpl) Delete

func (s *StoryStoreImpl) Delete(ctx context.Context, id uuid.UUID) error

Delete soft deletes a story

func (*StoryStoreImpl) GetByAuthorID

func (s *StoryStoreImpl) GetByAuthorID(ctx context.Context, authorID uuid.UUID, limit, offset int) ([]*models.Story, error)

GetByAuthorID gets stories by author ID

func (*StoryStoreImpl) GetByID

func (s *StoryStoreImpl) GetByID(ctx context.Context, id uuid.UUID) (*models.Story, error)

GetByID gets a story by ID with caching

func (*StoryStoreImpl) GetExpired

func (s *StoryStoreImpl) GetExpired(ctx context.Context, limit, offset int) ([]*models.Story, error)

GetExpired gets expired stories

func (*StoryStoreImpl) GetFeed

func (s *StoryStoreImpl) GetFeed(ctx context.Context, userID uuid.UUID, limit, offset int) ([]*models.Story, error)

GetFeed gets stories feed for a user

func (*StoryStoreImpl) GetPublic

func (s *StoryStoreImpl) GetPublic(ctx context.Context, limit, offset int) ([]*models.Story, error)

GetPublic gets public stories - ADDED MISSING METHOD

func (*StoryStoreImpl) GetViewCount

func (s *StoryStoreImpl) GetViewCount(ctx context.Context, storyID uuid.UUID) (int, error)

GetViewCount gets view count for a story

func (*StoryStoreImpl) IncrementViewCount

func (s *StoryStoreImpl) IncrementViewCount(ctx context.Context, storyID uuid.UUID) error

IncrementViewCount increments view count for a story

func (*StoryStoreImpl) Update

func (s *StoryStoreImpl) Update(ctx context.Context, story *models.Story) error

Update updates a story

type TopStoryMetric

type TopStoryMetric struct {
	StoryID   uuid.UUID `json:"story_id"`
	AuthorID  uuid.UUID `json:"author_id"`
	Views     int       `json:"views"`
	Reactions int       `json:"reactions"`
	Score     float64   `json:"score"`
}

type TopUserMetric

type TopUserMetric struct {
	UserID         uuid.UUID `json:"user_id"`
	StoriesPosted  int       `json:"stories_posted"`
	TotalViews     int       `json:"total_views"`
	TotalReactions int       `json:"total_reactions"`
	FollowerCount  int       `json:"follower_count"`
	Score          float64   `json:"score"`
}

type Transactional

type Transactional interface {
	WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error
}

Transaction interface for database operations

type UserMetrics

type UserMetrics struct {
	UserID            uuid.UUID `json:"user_id"`
	StoriesPosted     int       `json:"stories_posted"`
	ViewsReceived     int       `json:"views_received"`
	ReactionsReceived int       `json:"reactions_received"`
	FollowersGained   int       `json:"followers_gained"`
}

type UserStore

type UserStore interface {
	Create(ctx context.Context, user *models.User) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)
	GetByEmail(ctx context.Context, email string) (*models.User, error)
	GetByUsername(ctx context.Context, username string) (*models.User, error)
	Update(ctx context.Context, user *models.User) error
	Delete(ctx context.Context, id uuid.UUID) error
	Search(ctx context.Context, query string, limit, offset int) ([]*models.User, error)
	List(ctx context.Context, limit, offset int) ([]*models.User, error)
	UpdateStats(ctx context.Context, userID uuid.UUID, stats models.UserStats) error
	GetStats(ctx context.Context, userID uuid.UUID) (*models.UserStats, error)
}

UserStore defines the interface for user storage operations

func NewUserStore

func NewUserStore(db *sqlx.DB, redisClient *RedisClient, logger *zap.Logger) UserStore

NewUserStore creates a new user store

type UserStoreImpl

type UserStoreImpl struct {
	// contains filtered or unexported fields
}

UserStoreImpl implements UserStore interface

func (*UserStoreImpl) Create

func (s *UserStoreImpl) Create(ctx context.Context, user *models.User) error

Create creates a new user

func (*UserStoreImpl) Delete

func (s *UserStoreImpl) Delete(ctx context.Context, id uuid.UUID) error

Delete soft deletes a user

func (*UserStoreImpl) GetByEmail

func (s *UserStoreImpl) GetByEmail(ctx context.Context, email string) (*models.User, error)

GetByEmail gets a user by email

func (*UserStoreImpl) GetByID

func (s *UserStoreImpl) GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)

GetByID gets a user by ID with caching

func (*UserStoreImpl) GetByUsername

func (s *UserStoreImpl) GetByUsername(ctx context.Context, username string) (*models.User, error)

GetByUsername gets a user by username

func (*UserStoreImpl) GetStats

func (s *UserStoreImpl) GetStats(ctx context.Context, userID uuid.UUID) (*models.UserStats, error)

GetStats gets user statistics

func (*UserStoreImpl) List

func (s *UserStoreImpl) List(ctx context.Context, limit, offset int) ([]*models.User, error)

List gets a list of users

func (*UserStoreImpl) Search

func (s *UserStoreImpl) Search(ctx context.Context, query string, limit, offset int) ([]*models.User, error)

Search searches for users

func (*UserStoreImpl) Update

func (s *UserStoreImpl) Update(ctx context.Context, user *models.User) error

Update updates a user

func (*UserStoreImpl) UpdateStats

func (s *UserStoreImpl) UpdateStats(ctx context.Context, userID uuid.UUID, stats models.UserStats) error

UpdateStats updates user statistics

type ViewStore

type ViewStore interface {
	Create(ctx context.Context, view *models.StoryView) error
	GetByID(ctx context.Context, id uuid.UUID) (*models.StoryView, error)
	GetByStoryID(ctx context.Context, storyID uuid.UUID, limit, offset int) ([]*models.StoryViewWithUser, error)
	GetByViewerID(ctx context.Context, viewerID uuid.UUID, limit, offset int) ([]*models.StoryView, error)
	GetViewStats(ctx context.Context, storyID uuid.UUID) (*models.StoryViewStats, error)
	GetViewerStats(ctx context.Context, viewerID uuid.UUID) (*models.ViewerStats, error)
	HasViewed(ctx context.Context, storyID, viewerID uuid.UUID) (bool, error)
	GetViewAnalytics(ctx context.Context, storyID uuid.UUID, period string) (*models.ViewAnalytics, error)
	GetViewTrends(ctx context.Context, storyID uuid.UUID) ([]*models.ViewTrend, error)
}

ViewStore defines the interface for story view storage operations

func NewViewStore

func NewViewStore(db *sqlx.DB, redisClient *RedisClient, logger *zap.Logger) ViewStore

NewViewStore creates a new view store

type ViewStoreImpl

type ViewStoreImpl struct {
	// contains filtered or unexported fields
}

ViewStoreImpl implements ViewStore interface

func (*ViewStoreImpl) Create

func (s *ViewStoreImpl) Create(ctx context.Context, view *models.StoryView) error

Create creates a new story view

func (*ViewStoreImpl) GetByID

func (s *ViewStoreImpl) GetByID(ctx context.Context, id uuid.UUID) (*models.StoryView, error)

GetByID gets a story view by ID

func (*ViewStoreImpl) GetByStoryID

func (s *ViewStoreImpl) GetByStoryID(ctx context.Context, storyID uuid.UUID, limit, offset int) ([]*models.StoryViewWithUser, error)

GetByStoryID gets views for a specific story

func (*ViewStoreImpl) GetByViewerID

func (s *ViewStoreImpl) GetByViewerID(ctx context.Context, viewerID uuid.UUID, limit, offset int) ([]*models.StoryView, error)

GetByViewerID gets views by a specific viewer

func (*ViewStoreImpl) GetViewAnalytics

func (s *ViewStoreImpl) GetViewAnalytics(ctx context.Context, storyID uuid.UUID, period string) (*models.ViewAnalytics, error)

GetViewAnalytics gets analytics data for story views

func (*ViewStoreImpl) GetViewStats

func (s *ViewStoreImpl) GetViewStats(ctx context.Context, storyID uuid.UUID) (*models.StoryViewStats, error)

GetViewStats gets view statistics for a story

func (*ViewStoreImpl) GetViewTrends

func (s *ViewStoreImpl) GetViewTrends(ctx context.Context, storyID uuid.UUID) ([]*models.ViewTrend, error)

GetViewTrends gets view trend data over time - ADDED MISSING METHOD

func (*ViewStoreImpl) GetViewerStats

func (s *ViewStoreImpl) GetViewerStats(ctx context.Context, viewerID uuid.UUID) (*models.ViewerStats, error)

GetViewerStats gets viewing statistics for a user

func (*ViewStoreImpl) HasViewed

func (s *ViewStoreImpl) HasViewed(ctx context.Context, storyID, viewerID uuid.UUID) (bool, error)

HasViewed checks if a user has viewed a specific story

Jump to

Keyboard shortcuts

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