Documentation
¶
Index ¶
- Variables
- type CacheService
- type CommentService
- type GroupService
- func (s *GroupService) ConfirmGroup(ctx context.Context, group *types.ReviewGroup, reviewerID uint64) error
- func (s *GroupService) DeleteGroups(ctx context.Context, groupIDs []int64) (int64, error)
- func (s *GroupService) GetGroupToReview(ctx context.Context, sortBy enum.ReviewSortBy, ...) (*types.ReviewGroup, error)
- func (s *GroupService) MixGroup(ctx context.Context, group *types.ReviewGroup, reviewerID uint64) error
- func (s *GroupService) SaveGroups(ctx context.Context, groups map[int64]*types.ReviewGroup) error
- type ReviewerService
- type StatsService
- type SyncService
- type UserService
- func (s *UserService) ClearUser(ctx context.Context, user *types.ReviewUser, reviewerID uint64) error
- func (s *UserService) ClearUserWithTx(ctx context.Context, tx bun.Tx, user *types.ReviewUser, reviewerID uint64) error
- func (s *UserService) ConfirmUser(ctx context.Context, user *types.ReviewUser, reviewerID uint64) error
- func (s *UserService) ConfirmUsers(ctx context.Context, users []*types.ReviewUser, reviewerID uint64) error
- func (s *UserService) DeleteUser(ctx context.Context, userID int64) (bool, error)
- func (s *UserService) DeleteUsers(ctx context.Context, userIDs []int64) (int64, error)
- func (s *UserService) DeleteUsersWithTx(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)
- func (s *UserService) GetFlaggedUsersWithProfileReasons(ctx context.Context, confidenceThreshold float64, limit int) ([]*types.ReviewUser, error)
- func (s *UserService) GetUserByID(ctx context.Context, userID string, fields types.UserField) (*types.ReviewUser, error)
- func (s *UserService) GetUserRelationships(ctx context.Context, userID int64) (*types.ReviewUser, error)
- func (s *UserService) GetUserToReview(ctx context.Context, sortBy enum.ReviewSortBy, ...) (*types.ReviewUser, error)
- func (s *UserService) GetUsersByIDs(ctx context.Context, userIDs []int64, fields types.UserField) (map[int64]*types.ReviewUser, error)
- func (s *UserService) GetUsersRelationships(ctx context.Context, userIDs []int64, relationshipFields types.UserField) map[int64]*types.ReviewUser
- func (s *UserService) PurgeOldClearedUsers(ctx context.Context, cutoffDate time.Time) (int, error)
- func (s *UserService) SaveUsers(ctx context.Context, users map[int64]*types.ReviewUser) error
- func (s *UserService) UpdateToPastOffender(ctx context.Context, userIDs []int64) error
- type ViewService
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidComment = errors.New("invalid comment message") ErrCommentTooSimilar = errors.New("comment too similar to existing ones") )
Functions ¶
This section is empty.
Types ¶
type CacheService ¶
type CacheService struct {
// contains filtered or unexported fields
}
CacheService handles cache-related business logic.
func NewCache ¶
func NewCache(db *bun.DB, model *models.CacheModel, logger *zap.Logger) *CacheService
NewCache creates a new cache service.
func (*CacheService) FilterProcessedUsers ¶
FilterProcessedUsers filters out user IDs that have been processed within their dynamic processing interval.
func (*CacheService) MarkUsersProcessed ¶
func (s *CacheService) MarkUsersProcessed(ctx context.Context, userCreationDates map[int64]time.Time) error
MarkUsersProcessed marks users as processed with calculated times based on their account age.
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
CommentService handles comment-related business logic.
func NewComment ¶
func NewComment(model *models.CommentModel, logger *zap.Logger) *CommentService
NewComment creates a new comment service.
func (*CommentService) AddGroupComment ¶
func (s *CommentService) AddGroupComment(ctx context.Context, comment *types.GroupComment) error
AddGroupComment adds a new comment for a group with spam prevention.
func (*CommentService) AddUserComment ¶
func (s *CommentService) AddUserComment(ctx context.Context, comment *types.UserComment) error
AddUserComment adds a new comment for a user with spam prevention.
type GroupService ¶
type GroupService struct {
// contains filtered or unexported fields
}
GroupService handles group-related business logic.
func NewGroup ¶
func NewGroup( db *bun.DB, model *models.GroupModel, activity *models.ActivityModel, tracking *models.TrackingModel, logger *zap.Logger, ) *GroupService
NewGroup creates a new group service.
func (*GroupService) ConfirmGroup ¶
func (s *GroupService) ConfirmGroup(ctx context.Context, group *types.ReviewGroup, reviewerID uint64) error
ConfirmGroup moves a group to confirmed status and creates a verification record.
func (*GroupService) DeleteGroups ¶
DeleteGroups removes groups and all associated data including tracking.
func (*GroupService) GetGroupToReview ¶
func (s *GroupService) GetGroupToReview( ctx context.Context, sortBy enum.ReviewSortBy, targetMode enum.ReviewTargetMode, reviewerID uint64, ) (*types.ReviewGroup, error)
GetGroupToReview finds a group to review based on the sort method and target mode.
func (*GroupService) MixGroup ¶
func (s *GroupService) MixGroup(ctx context.Context, group *types.ReviewGroup, reviewerID uint64) error
MixGroup moves a group to mixed status and creates a mixed classification record.
func (*GroupService) SaveGroups ¶
func (s *GroupService) SaveGroups(ctx context.Context, groups map[int64]*types.ReviewGroup) error
SaveGroups handles the business logic for saving groups.
type ReviewerService ¶
type ReviewerService struct {
// contains filtered or unexported fields
}
ReviewerService handles reviewer-related business logic.
func NewReviewer ¶
func NewReviewer( model *models.ReviewerModel, views *ViewService, logger *zap.Logger, ) *ReviewerService
NewReviewer creates a new reviewer service.
func (*ReviewerService) GetReviewerStats ¶
func (s *ReviewerService) GetReviewerStats( ctx context.Context, period enum.ReviewerStatsPeriod, cursor *types.ReviewerStatsCursor, limit int, ) (map[uint64]*types.ReviewerStats, *types.ReviewerStatsCursor, error)
GetReviewerStats retrieves paginated reviewer statistics for a specific time period.
type StatsService ¶
type StatsService struct {
// contains filtered or unexported fields
}
StatsService handles statistics-related business logic.
func NewStats ¶
func NewStats( model *models.StatsModel, user *models.UserModel, group *models.GroupModel, logger *zap.Logger, ) *StatsService
NewStats creates a new stats service.
func (*StatsService) GetCurrentCounts ¶
func (s *StatsService) GetCurrentCounts(ctx context.Context) (*types.UserCounts, *types.GroupCounts, error)
GetCurrentCounts retrieves all current user and group counts.
func (*StatsService) GetCurrentStats ¶
func (s *StatsService) GetCurrentStats(ctx context.Context) (*types.HourlyStats, error)
GetCurrentStats retrieves the current statistics by counting directly from relevant tables.
func (*StatsService) SaveHourlyStats ¶
func (s *StatsService) SaveHourlyStats(ctx context.Context) error
SaveHourlyStats saves the current statistics snapshot.
type SyncService ¶
type SyncService struct {
// contains filtered or unexported fields
}
SyncService handles user sync-related operations.
func NewSync ¶
func NewSync(sync *models.SyncModel, logger *zap.Logger) *SyncService
NewSync creates a new sync service.
func (*SyncService) ShouldSkipUser ¶
func (s *SyncService) ShouldSkipUser( ctx context.Context, userID uint64, ) (isRedacted, isWhitelisted bool, err error)
ShouldSkipUser checks if a user's data should be skipped due to privacy settings. Returns true if the user should be skipped (is redacted or whitelisted).
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService handles user-related business logic.
func NewUser ¶
func NewUser( db *bun.DB, model *models.UserModel, activity *models.ActivityModel, tracking *models.TrackingModel, cache *models.CacheModel, logger *zap.Logger, ) *UserService
NewUser creates a new user service.
func (*UserService) ClearUser ¶
func (s *UserService) ClearUser(ctx context.Context, user *types.ReviewUser, reviewerID uint64) error
ClearUser moves a user to cleared status and creates a clearance record.
func (*UserService) ClearUserWithTx ¶
func (s *UserService) ClearUserWithTx(ctx context.Context, tx bun.Tx, user *types.ReviewUser, reviewerID uint64) error
ClearUserWithTx moves a user to cleared status and creates a clearance record using the provided transaction.
func (*UserService) ConfirmUser ¶
func (s *UserService) ConfirmUser(ctx context.Context, user *types.ReviewUser, reviewerID uint64) error
ConfirmUser moves a user to confirmed status and creates a verification record.
func (*UserService) ConfirmUsers ¶
func (s *UserService) ConfirmUsers(ctx context.Context, users []*types.ReviewUser, reviewerID uint64) error
ConfirmUsers moves multiple users to confirmed status and creates verification records.
func (*UserService) DeleteUser ¶
DeleteUser removes a single user and all associated data from the database.
func (*UserService) DeleteUsers ¶
DeleteUsers removes multiple users and all their associated data from the database.
func (*UserService) DeleteUsersWithTx ¶
func (s *UserService) DeleteUsersWithTx(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)
DeleteUsersWithTx removes multiple users and all their associated data from the database using the provided transaction.
func (*UserService) GetFlaggedUsersWithProfileReasons ¶
func (s *UserService) GetFlaggedUsersWithProfileReasons( ctx context.Context, confidenceThreshold float64, limit int, ) ([]*types.ReviewUser, error)
GetFlaggedUsersWithProfileReasons returns flagged users that have profile reasons with confidence above the specified threshold, including all their reason data.
func (*UserService) GetUserByID ¶
func (s *UserService) GetUserByID( ctx context.Context, userID string, fields types.UserField, ) (*types.ReviewUser, error)
GetUserByID retrieves a user by either their numeric ID or UUID.
func (*UserService) GetUserRelationships ¶
func (s *UserService) GetUserRelationships(ctx context.Context, userID int64) (*types.ReviewUser, error)
GetUserRelationships fetches all relationships for a user.
func (*UserService) GetUserToReview ¶
func (s *UserService) GetUserToReview( ctx context.Context, sortBy enum.ReviewSortBy, targetMode enum.ReviewTargetMode, reviewerID uint64, ) (*types.ReviewUser, error)
GetUserToReview finds a user to review based on the sort method and target mode.
func (*UserService) GetUsersByIDs ¶
func (s *UserService) GetUsersByIDs( ctx context.Context, userIDs []int64, fields types.UserField, ) (map[int64]*types.ReviewUser, error)
GetUsersByIDs retrieves multiple users by their IDs with specified fields.
func (*UserService) GetUsersRelationships ¶
func (s *UserService) GetUsersRelationships( ctx context.Context, userIDs []int64, relationshipFields types.UserField, ) map[int64]*types.ReviewUser
GetUsersRelationships fetches only the requested relationships for multiple users.
func (*UserService) PurgeOldClearedUsers ¶
PurgeOldClearedUsers removes cleared users older than the cutoff date.
func (*UserService) SaveUsers ¶
func (s *UserService) SaveUsers(ctx context.Context, users map[int64]*types.ReviewUser) error
SaveUsers handles the business logic for saving users.
func (*UserService) UpdateToPastOffender ¶
func (s *UserService) UpdateToPastOffender(ctx context.Context, userIDs []int64) error
UpdateToPastOffender updates users to past offender status when they become clean.
type ViewService ¶
type ViewService struct {
// contains filtered or unexported fields
}
ViewService handles materialized view business logic.
func NewView ¶
func NewView(model *models.MaterializedViewModel, logger *zap.Logger) *ViewService
NewView creates a new view service.
func (*ViewService) GetReviewerStatsRefreshInfo ¶
func (s *ViewService) GetReviewerStatsRefreshInfo( ctx context.Context, period enum.ReviewerStatsPeriod, ) (lastRefresh, nextRefresh time.Time, err error)
GetReviewerStatsRefreshInfo returns the last refresh time and next scheduled refresh for a reviewer stats view.
func (*ViewService) RefreshReviewerStatsView ¶
func (s *ViewService) RefreshReviewerStatsView(ctx context.Context, period enum.ReviewerStatsPeriod) error
RefreshReviewerStatsView refreshes reviewer statistics for a specific period.