Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateExternalActivity(a *Activity) error
- type Activity
- type ActivityRepository
- func (r *ActivityRepository) Create(ctx context.Context, activity *Activity) error
- func (r *ActivityRepository) DeleteByID(ctx context.Context, id uint64) error
- func (r *ActivityRepository) GetAllByUserID(ctx context.Context, userID, guildID string) ([]*Activity, error)
- func (r *ActivityRepository) GetAvgSpeedByMediaTypeAndUserID(ctx context.Context, mediaType, userID string, start, end time.Time) (float32, error)
- func (r *ActivityRepository) GetByID(ctx context.Context, id uint64, guildID string) (*Activity, error)
- func (r *ActivityRepository) GetLatestByUserID(ctx context.Context, userID, guildID string) (*Activity, error)
- func (r *ActivityRepository) GetLatestYouTubeChannelNamesByUserIDAndChannelID(ctx context.Context, userID string, channelID ...string) ([]string, error)
- func (r *ActivityRepository) GetRecentImportsByUserID(ctx context.Context, userID string, limit int) ([]ImportInfo, error)
- func (r *ActivityRepository) GetTopMembers(ctx context.Context, guildID string, limit int, start, end time.Time) ([]*MemberStats, error)
- func (r *ActivityRepository) GetTotalByUserIDGroupByVideoChannel(ctx context.Context, userID string, start, end time.Time, limit int) (orderedmap.Map[ChannelStats], error)
- func (r *ActivityRepository) GetTotalByUserIDGroupedByDay(ctx context.Context, userID, guildID string, start, end time.Time) (orderedmap.Map[time.Duration], error)
- func (r *ActivityRepository) GetTotalByUserIDGroupedByMonth(ctx context.Context, userID, guildID string, start, end time.Time) (orderedmap.Map[time.Duration], error)
- func (r *ActivityRepository) GetTotalWatchTimeOfVideoByUserID(ctx context.Context, userID, videoPlatform, videoID string) (total time.Duration, err error)
- func (r *ActivityRepository) GetTotalYouTubeWatchTimeByUserID(ctx context.Context, userID string, start, end time.Time) (time.Duration, error)
- func (r *ActivityRepository) ImportMany(ctx context.Context, as []*Activity) error
- func (r *ActivityRepository) PageByUserID(ctx context.Context, userID, guildID string, limit, offset int) (*UserActivityPage, error)
- func (r *ActivityRepository) UndoImportByUserIDAndTimestamp(ctx context.Context, userID string, timestamp time.Time) (int64, error)
- type ChannelStats
- type ImportInfo
- type MemberStats
- type UserActivityPage
Constants ¶
View Source
const ( ActivityImmersionTypeReading = "reading" ActivityImmersionTypeListening = "listening" )
View Source
const ( ActivityMediaTypeManga = "manga" ActivityMediaTypeAnime = "anime" ActivityMediaTypeVideo = "video" ActivityMediaTypeBook = "book" ActivityMediaTypeVisualNovel = "visual_novel" )
Variables ¶
View Source
var ( ErrInvalidNameLength = errors.New("name must be of length <100") ErrInvalidMediaType = errors.New("invalid media type") ErrInvalidPrimaryType = errors.New("invalid primary type") ErrInvalidGuildID = errors.New("guild id should be a valid discord snowflake") ErrInvalidUserID = errors.New("user id should be a valid discord snowflake") )
Functions ¶
Types ¶
type Activity ¶
type Activity struct { ID uint64 `json:"id"` UserID string `json:"user_id"` GuildID *string `json:"guild_id"` Name string `json:"name"` PrimaryType string `json:"primary_type"` MediaType *string `json:"media_type"` Duration time.Duration `json:"duration"` Date time.Time `json:"date"` Meta interface{} `json:"meta"` CreatedAt time.Time `json:"created_at"` DeletedAt *time.Time `json:"deleted_at"` ImportedAt *time.Time `json:"imported_at"` }
func NewActivity ¶
func NewActivity() *Activity
type ActivityRepository ¶
type ActivityRepository struct {
// contains filtered or unexported fields
}
func NewActivityRepository ¶
func NewActivityRepository(pool *pgxpool.Pool) *ActivityRepository
func (*ActivityRepository) Create ¶
func (r *ActivityRepository) Create(ctx context.Context, activity *Activity) error
func (*ActivityRepository) DeleteByID ¶
func (r *ActivityRepository) DeleteByID(ctx context.Context, id uint64) error
func (*ActivityRepository) GetAllByUserID ¶
func (*ActivityRepository) GetAvgSpeedByMediaTypeAndUserID ¶
func (*ActivityRepository) GetLatestByUserID ¶
func (*ActivityRepository) GetLatestYouTubeChannelNamesByUserIDAndChannelID ¶
func (*ActivityRepository) GetRecentImportsByUserID ¶
func (r *ActivityRepository) GetRecentImportsByUserID( ctx context.Context, userID string, limit int, ) ([]ImportInfo, error)
func (*ActivityRepository) GetTopMembers ¶
func (r *ActivityRepository) GetTopMembers(ctx context.Context, guildID string, limit int, start, end time.Time) ([]*MemberStats, error)
func (*ActivityRepository) GetTotalByUserIDGroupByVideoChannel ¶
func (r *ActivityRepository) GetTotalByUserIDGroupByVideoChannel( ctx context.Context, userID string, start, end time.Time, limit int, ) (orderedmap.Map[ChannelStats], error)
func (*ActivityRepository) GetTotalByUserIDGroupedByDay ¶
func (r *ActivityRepository) GetTotalByUserIDGroupedByDay( ctx context.Context, userID, guildID string, start, end time.Time, ) (orderedmap.Map[time.Duration], error)
Returns map of day (YYYY-MM-DD) to total duration filling in missing days with 0 (string formatted according to user's timezone)
func (*ActivityRepository) GetTotalByUserIDGroupedByMonth ¶
func (*ActivityRepository) GetTotalWatchTimeOfVideoByUserID ¶
func (*ActivityRepository) GetTotalYouTubeWatchTimeByUserID ¶
func (*ActivityRepository) ImportMany ¶
func (r *ActivityRepository) ImportMany(ctx context.Context, as []*Activity) error
func (*ActivityRepository) PageByUserID ¶
func (r *ActivityRepository) PageByUserID( ctx context.Context, userID, guildID string, limit, offset int, ) (*UserActivityPage, error)
func (*ActivityRepository) UndoImportByUserIDAndTimestamp ¶
type ChannelStats ¶
type ImportInfo ¶
type MemberStats ¶
type UserActivityPage ¶
Click to show internal directories.
Click to hide internal directories.