Documentation
¶
Index ¶
- type StatHandler
- func (h *StatHandler) CountPosts(c *gin.Context)
- func (h *StatHandler) GetAllPostsStats(c *gin.Context)
- func (h *StatHandler) GetDetailedPostStats(c *gin.Context)
- func (h *StatHandler) GetDetailedStats(c *gin.Context)
- func (h *StatHandler) GetPostStats(c *gin.Context)
- func (h *StatHandler) GetPostsCreatedInLastDays(c *gin.Context)
- func (h *StatHandler) IncrementShare(c *gin.Context)
- type StatRepository
- type StatService
- func (s *StatService) CountPosts() (int64, error)
- func (s *StatService) GetAllPostsStats() ([]*models.PostStats, error)
- func (s *StatService) GetDetailedPostStats() (*models.DetailedStatsResponse, error)
- func (s *StatService) GetPostStats(postID uint) (*models.PostDetailedResponse, error)
- func (s *StatService) GetPostsCreatedInLastDays(days int) ([]*models.Post, error)
- func (s *StatService) GetVisitorStats(startDate, endDate time.Time) (*models.StatsResponse, error)
- func (s *StatService) IncrementShareCount(postID uint) error
- type StatsWorker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StatHandler ¶
type StatHandler struct {
// contains filtered or unexported fields
}
func NewStatHandler ¶
func NewStatHandler(statService *StatService) *StatHandler
func (*StatHandler) CountPosts ¶
func (h *StatHandler) CountPosts(c *gin.Context)
CountPosts godoc @Summary Get the total number of posts @Description Fetch the total number of active posts @Tags Stats @Accept json @Produce json @Success 200 {object} models.CountResponse "count: total number of posts" @Failure 500 {object} models.ErrorResponse "Internal Server Error" @Router /posts/count [get]
func (*StatHandler) GetAllPostsStats ¶
func (h *StatHandler) GetAllPostsStats(c *gin.Context)
GetAllPostsStats godoc @Summary Get statistics for all posts @Description Fetch statistics for all posts, including views, likes, and shares @Tags Stats @Accept json @Produce json @Success 200 {array} models.PostStats @Failure 500 {object} models.ErrorResponse "Internal Server Error" @Router /posts/stats [get]
func (*StatHandler) GetDetailedPostStats ¶
func (h *StatHandler) GetDetailedPostStats(c *gin.Context)
GetDetailedPostStats godoc @Summary Get detailed statistics for all posts @Description Get comprehensive statistics for all posts including totals @Tags Stats @Accept json @Produce json @Success 200 {object} models.DetailedStatsResponse @Failure 500 {object} models.ErrorResponse @Router /admin/posts/detailed-stats [get]
func (*StatHandler) GetDetailedStats ¶
func (h *StatHandler) GetDetailedStats(c *gin.Context)
GetDetailedStats godoc @Summary Get detailed statistics @Description Get comprehensive statistics about website traffic and engagement @Tags Stats @Accept json @Produce json @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Success 200 {object} models.StatsResponse @Failure 500 {object} models.ErrorResponse @Router /admin/stats/detailed [get]
func (*StatHandler) GetPostStats ¶
func (h *StatHandler) GetPostStats(c *gin.Context)
GetPostStats godoc @Summary Get statistics for a specific post @Description Fetch statistics such as views, likes, and shares for a given post by its ID @Tags Stats @Accept json @Produce json @Param id path int true "Post ID" @Success 200 {object} models.Stat @Failure 404 {object} models.ErrorResponse "Post not found" @Failure 500 {object} models.ErrorResponse "Internal Server Error" @Router /posts/{id}/stats [get]
func (*StatHandler) GetPostsCreatedInLastDays ¶
func (h *StatHandler) GetPostsCreatedInLastDays(c *gin.Context)
GetPostsCreatedInLastDays godoc @Summary Get posts created in the last X days @Description Fetch posts that were created within the last X days @Tags Stats @Accept json @Produce json @Param days path int true "Number of days" @Success 200 {array} models.Post @Failure 400 {object} models.ErrorResponse "Invalid days parameter" @Failure 500 {object} models.ErrorResponse "Internal Server Error" @Router /posts/recent/{days} [get]
func (*StatHandler) IncrementShare ¶
func (h *StatHandler) IncrementShare(c *gin.Context)
type StatRepository ¶
type StatRepository interface { GetPostStats(uint) (*models.PostDetailedResponse, error) GetAllPostsStats() ([]*models.PostStats, error) CountPosts() (int64, error) GetPostsCreatedInLastDays(days int) ([]*models.Post, error) RecordVisit(visitor *models.Visitor) error RecordPostView(view *models.PostView) error UpdateDailyStats(stat *models.DailyStat) error GetVisitorStats(startDate, endDate time.Time) (*models.StatsResponse, error) GetDetailedPostStats() (*models.DetailedStatsResponse, error) }
func NewStatRepository ¶
func NewStatRepository(db *gorm.DB) StatRepository
type StatService ¶
type StatService struct {
// contains filtered or unexported fields
}
func NewStatService ¶
func NewStatService(statRepo StatRepository) *StatService
func (*StatService) CountPosts ¶
func (s *StatService) CountPosts() (int64, error)
func (*StatService) GetAllPostsStats ¶
func (s *StatService) GetAllPostsStats() ([]*models.PostStats, error)
func (*StatService) GetDetailedPostStats ¶
func (s *StatService) GetDetailedPostStats() (*models.DetailedStatsResponse, error)
func (*StatService) GetPostStats ¶
func (s *StatService) GetPostStats(postID uint) (*models.PostDetailedResponse, error)
func (*StatService) GetPostsCreatedInLastDays ¶
func (s *StatService) GetPostsCreatedInLastDays(days int) ([]*models.Post, error)
func (*StatService) GetVisitorStats ¶
func (s *StatService) GetVisitorStats(startDate, endDate time.Time) (*models.StatsResponse, error)
func (*StatService) IncrementShareCount ¶
func (s *StatService) IncrementShareCount(postID uint) error
type StatsWorker ¶
type StatsWorker struct {
// contains filtered or unexported fields
}
func NewStatsWorker ¶
func NewStatsWorker(repo StatRepository, workerCount int, logger *logrus.Logger) *StatsWorker
func (*StatsWorker) QueueView ¶
func (w *StatsWorker) QueueView(view *models.PostView)
func (*StatsWorker) QueueVisit ¶
func (w *StatsWorker) QueueVisit(visitor *models.Visitor)
func (*StatsWorker) Start ¶
func (w *StatsWorker) Start()