Documentation
¶
Index ¶
- type EligibleVideo
- type GeneratedMessage
- type JSONB
- type PlatformAccount
- type PlatformAccountRepository
- func (r *PlatformAccountRepository) Count(ctx context.Context) (int, error)
- func (r *PlatformAccountRepository) Create(ctx context.Context, account *PlatformAccount) error
- func (r *PlatformAccountRepository) GetAccountStatus(ctx context.Context) ([]PlatformAccountStatus, error)
- func (r *PlatformAccountRepository) GetAccountsDueForPosting(ctx context.Context) ([]PlatformAccount, error)
- func (r *PlatformAccountRepository) GetByID(ctx context.Context, id string) (*PlatformAccount, error)
- func (r *PlatformAccountRepository) GetByPlatformAndHandle(ctx context.Context, platform PlatformType, handle string) (*PlatformAccount, error)
- func (r *PlatformAccountRepository) ListActive(ctx context.Context) ([]PlatformAccount, error)
- func (r *PlatformAccountRepository) ListAll(ctx context.Context) ([]PlatformAccount, error)
- func (r *PlatformAccountRepository) ListByPlatform(ctx context.Context, platform PlatformType) ([]PlatformAccount, error)
- func (r *PlatformAccountRepository) SetActive(ctx context.Context, accountID string, active bool) error
- func (r *PlatformAccountRepository) Update(ctx context.Context, account *PlatformAccount) error
- func (r *PlatformAccountRepository) UpdateLastPostedAt(ctx context.Context, accountID string, postedAt time.Time) error
- type PlatformAccountStatus
- type PlatformType
- type Post
- type PostHistory
- type PostRepository
- func (r *PostRepository) Create(ctx context.Context, post *Post) error
- func (r *PostRepository) CreatePostHistory(ctx context.Context, history *PostHistory) error
- func (r *PostRepository) GetByID(ctx context.Context, id string) (*Post, error)
- func (r *PostRepository) GetGeneratedMessages(ctx context.Context, postID string) ([]GeneratedMessage, error)
- func (r *PostRepository) GetLastPostForVideo(ctx context.Context, accountID string, videoID string) (*PostHistory, error)
- func (r *PostRepository) GetPostHistoryForAccount(ctx context.Context, accountID string, limit int) ([]PostHistory, error)
- func (r *PostRepository) GetPostStats(ctx context.Context) (map[string]interface{}, error)
- func (r *PostRepository) GetQueuedPosts(ctx context.Context, limit int) ([]Post, error)
- func (r *PostRepository) IncrementIterationCount(ctx context.Context, postID string) error
- func (r *PostRepository) IncrementRetryCount(ctx context.Context, postID string) error
- func (r *PostRepository) ListByStatus(ctx context.Context, status PostStatus) ([]Post, error)
- func (r *PostRepository) MarkAsFailed(ctx context.Context, postID string, status PostStatus, errorMessage string, ...) error
- func (r *PostRepository) MarkAsPosted(ctx context.Context, postID string, platformPostID string, platformURL string) error
- func (r *PostRepository) SaveGeneratedMessage(ctx context.Context, msg *GeneratedMessage) error
- func (r *PostRepository) UpdateEngagementMetrics(ctx context.Context, historyID string, metrics JSONB) error
- func (r *PostRepository) UpdateStatus(ctx context.Context, postID string, status PostStatus) error
- func (r *PostRepository) UpdateWithMessage(ctx context.Context, postID string, messageText string, metadata JSONB) error
- type PostStatus
- type SupabaseConnection
- type Video
- type VideoRepository
- func (r *VideoRepository) Count(ctx context.Context) (int, error)
- func (r *VideoRepository) Create(ctx context.Context, video *Video) error
- func (r *VideoRepository) GetByID(ctx context.Context, id string) (*Video, error)
- func (r *VideoRepository) GetByVideoID(ctx context.Context, videoID string) (*Video, error)
- func (r *VideoRepository) GetEligibleVideos(ctx context.Context, platformAccountID string) ([]EligibleVideo, error)
- func (r *VideoRepository) GetRandomEligibleVideo(ctx context.Context, platformAccountID string) (*EligibleVideo, error)
- func (r *VideoRepository) ListAll(ctx context.Context) ([]Video, error)
- func (r *VideoRepository) ListByChannel(ctx context.Context, channelID string) ([]Video, error)
- func (r *VideoRepository) Update(ctx context.Context, video *Video) error
- func (r *VideoRepository) VideoExists(ctx context.Context, videoID string) (bool, error)
- type YouTubeChannel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EligibleVideo ¶
type EligibleVideo struct {
ID string `db:"id" json:"id"`
VideoID string `db:"video_id" json:"video_id"`
Title string `db:"title" json:"title"`
URL string `db:"url" json:"url"`
ChannelID string `db:"channel_id" json:"channel_id"`
PlatformAccountID string `db:"platform_account_id" json:"platform_account_id"`
Platform PlatformType `db:"platform" json:"platform"`
AccountHandle string `db:"account_handle" json:"account_handle"`
PublishedAt *time.Time `db:"published_at" json:"published_at,omitempty"`
LastPostedToAccount time.Time `db:"last_posted_to_account" json:"last_posted_to_account"`
DaysSinceLastPost float64 `db:"days_since_last_post" json:"days_since_last_post"`
CooldownDays int `db:"cooldown_days" json:"cooldown_days"`
}
EligibleVideo represents a video eligible for posting to an account
type GeneratedMessage ¶
type GeneratedMessage struct {
ID string `db:"id" json:"id"`
PostID string `db:"post_id" json:"post_id"`
Platform PlatformType `db:"platform" json:"platform"`
MessageText string `db:"message_text" json:"message_text"`
PromptTemplate *string `db:"prompt_template" json:"prompt_template,omitempty"`
ModelUsed *string `db:"model_used" json:"model_used,omitempty"`
ValidationStatus *string `db:"validation_status" json:"validation_status,omitempty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
PromptVariables JSONB `db:"prompt_variables" json:"prompt_variables"`
ValidationErrors JSONB `db:"validation_errors" json:"validation_errors"`
Metadata JSONB `db:"metadata" json:"metadata"`
IterationNumber int `db:"iteration_number" json:"iteration_number"`
TokenCount *int `db:"token_count" json:"token_count,omitempty"`
CharacterCount *int `db:"character_count" json:"character_count,omitempty"`
GenerationTimeMs *int `db:"generation_time_ms" json:"generation_time_ms,omitempty"`
}
GeneratedMessage represents an LLM-generated message
type JSONB ¶
type JSONB map[string]interface{}
JSONB is a custom type that allows storing JSON data in PostgreSQL JSONB columns
type PlatformAccount ¶
type PlatformAccount struct {
ID string `db:"id" json:"id"`
Platform PlatformType `db:"platform" json:"platform"`
AccountHandle string `db:"account_handle" json:"account_handle"`
CredentialKey string `db:"credential_key" json:"credential_key"`
DisplayName *string `db:"display_name" json:"display_name,omitempty"`
LastPostedAt *time.Time `db:"last_posted_at" json:"last_posted_at,omitempty"`
NextPostDueAt *time.Time `db:"next_post_due_at" json:"next_post_due_at,omitempty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Metadata JSONB `db:"metadata" json:"metadata"`
PostingScheduleDays int `db:"posting_schedule_days" json:"posting_schedule_days"`
CooldownDays int `db:"cooldown_days" json:"cooldown_days"`
IsActive bool `db:"is_active" json:"is_active"`
}
PlatformAccount represents a configured social media account
type PlatformAccountRepository ¶
type PlatformAccountRepository struct {
// contains filtered or unexported fields
}
PlatformAccountRepository handles all platform account-related database operations
func NewPlatformAccountRepository ¶
func NewPlatformAccountRepository(conn *SupabaseConnection) *PlatformAccountRepository
NewPlatformAccountRepository creates a new PlatformAccountRepository
func (*PlatformAccountRepository) Count ¶
func (r *PlatformAccountRepository) Count(ctx context.Context) (int, error)
Count returns the total number of platform accounts
func (*PlatformAccountRepository) Create ¶
func (r *PlatformAccountRepository) Create(ctx context.Context, account *PlatformAccount) error
Create inserts a new platform account
func (*PlatformAccountRepository) GetAccountStatus ¶
func (r *PlatformAccountRepository) GetAccountStatus(ctx context.Context) ([]PlatformAccountStatus, error)
GetAccountStatus retrieves the posting status for all accounts
func (*PlatformAccountRepository) GetAccountsDueForPosting ¶
func (r *PlatformAccountRepository) GetAccountsDueForPosting(ctx context.Context) ([]PlatformAccount, error)
GetAccountsDueForPosting retrieves accounts that are due for posting An account is due if: 1. It's active 2. next_post_due_at is NULL or in the past OR 3. last_posted_at is NULL or (now - last_posted_at) >= posting_schedule_days
func (*PlatformAccountRepository) GetByID ¶
func (r *PlatformAccountRepository) GetByID(ctx context.Context, id string) (*PlatformAccount, error)
GetByID retrieves a platform account by its UUID
func (*PlatformAccountRepository) GetByPlatformAndHandle ¶
func (r *PlatformAccountRepository) GetByPlatformAndHandle(ctx context.Context, platform PlatformType, handle string) (*PlatformAccount, error)
GetByPlatformAndHandle retrieves a platform account by platform and handle
func (*PlatformAccountRepository) ListActive ¶
func (r *PlatformAccountRepository) ListActive(ctx context.Context) ([]PlatformAccount, error)
ListActive retrieves all active platform accounts
func (*PlatformAccountRepository) ListAll ¶
func (r *PlatformAccountRepository) ListAll(ctx context.Context) ([]PlatformAccount, error)
ListAll retrieves all platform accounts
func (*PlatformAccountRepository) ListByPlatform ¶
func (r *PlatformAccountRepository) ListByPlatform(ctx context.Context, platform PlatformType) ([]PlatformAccount, error)
ListByPlatform retrieves all accounts for a specific platform
func (*PlatformAccountRepository) SetActive ¶
func (r *PlatformAccountRepository) SetActive(ctx context.Context, accountID string, active bool) error
SetActive enables or disables a platform account
func (*PlatformAccountRepository) Update ¶
func (r *PlatformAccountRepository) Update(ctx context.Context, account *PlatformAccount) error
Update updates an existing platform account
func (*PlatformAccountRepository) UpdateLastPostedAt ¶
func (r *PlatformAccountRepository) UpdateLastPostedAt(ctx context.Context, accountID string, postedAt time.Time) error
UpdateLastPostedAt updates the last_posted_at timestamp and calculates next_post_due_at
type PlatformAccountStatus ¶
type PlatformAccountStatus struct {
ID string `db:"id" json:"id"`
Platform PlatformType `db:"platform" json:"platform"`
AccountHandle string `db:"account_handle" json:"account_handle"`
LastPostedAt *time.Time `db:"last_posted_at" json:"last_posted_at,omitempty"`
NextPostDueAt *time.Time `db:"next_post_due_at" json:"next_post_due_at,omitempty"`
DaysSinceLastPost float64 `db:"days_since_last_post" json:"days_since_last_post"`
PostingScheduleDays int `db:"posting_schedule_days" json:"posting_schedule_days"`
CooldownDays int `db:"cooldown_days" json:"cooldown_days"`
TotalVideosPosted int `db:"total_videos_posted" json:"total_videos_posted"`
VideosPostedLast30Days int `db:"videos_posted_last_30_days" json:"videos_posted_last_30_days"`
IsActive bool `db:"is_active" json:"is_active"`
}
PlatformAccountStatus represents the posting status of an account
type PlatformType ¶
type PlatformType string
PlatformType represents the social media platform
const ( PlatformTwitter PlatformType = "twitter" PlatformLinkedIn PlatformType = "linkedin" PlatformDiscord PlatformType = "discord" PlatformBluesky PlatformType = "bluesky" )
type Post ¶
type Post struct {
ID string `db:"id" json:"id"`
PlatformAccountID string `db:"platform_account_id" json:"platform_account_id"`
VideoID string `db:"video_id" json:"video_id"`
Status PostStatus `db:"status" json:"status"`
MessageText *string `db:"message_text" json:"message_text,omitempty"`
PlatformPostID *string `db:"platform_post_id" json:"platform_post_id,omitempty"`
PlatformURL *string `db:"platform_url" json:"platform_url,omitempty"`
ErrorMessage *string `db:"error_message" json:"error_message,omitempty"`
ErrorCode *string `db:"error_code" json:"error_code,omitempty"`
StartedAt *time.Time `db:"started_at" json:"started_at,omitempty"`
PostedAt *time.Time `db:"posted_at" json:"posted_at,omitempty"`
FailedAt *time.Time `db:"failed_at" json:"failed_at,omitempty"`
QueuedAt time.Time `db:"queued_at" json:"queued_at"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
MessageMetadata JSONB `db:"message_metadata" json:"message_metadata"`
RetryCount int `db:"retry_count" json:"retry_count"`
Tier2IterationCount int `db:"tier_2_iteration_count" json:"tier_2_iteration_count"`
}
Post represents a posting attempt
type PostHistory ¶
type PostHistory struct {
ID string `db:"id" json:"id"`
PlatformAccountID string `db:"platform_account_id" json:"platform_account_id"`
VideoID string `db:"video_id" json:"video_id"`
PostID string `db:"post_id" json:"post_id"`
PlatformPostID *string `db:"platform_post_id" json:"platform_post_id,omitempty"`
PlatformURL *string `db:"platform_url" json:"platform_url,omitempty"`
MessageText *string `db:"message_text" json:"message_text,omitempty"`
PostedAt time.Time `db:"posted_at" json:"posted_at"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
EngagementMetrics JSONB `db:"engagement_metrics" json:"engagement_metrics"`
}
PostHistory represents the audit trail of successful posts
type PostRepository ¶
type PostRepository struct {
// contains filtered or unexported fields
}
PostRepository handles all post-related database operations
func NewPostRepository ¶
func NewPostRepository(conn *SupabaseConnection) *PostRepository
NewPostRepository creates a new PostRepository
func (*PostRepository) Create ¶
func (r *PostRepository) Create(ctx context.Context, post *Post) error
Create inserts a new post
func (*PostRepository) CreatePostHistory ¶
func (r *PostRepository) CreatePostHistory(ctx context.Context, history *PostHistory) error
CreatePostHistory creates a post history record for a successful post
func (*PostRepository) GetGeneratedMessages ¶
func (r *PostRepository) GetGeneratedMessages(ctx context.Context, postID string) ([]GeneratedMessage, error)
GetGeneratedMessages retrieves all generated messages for a post
func (*PostRepository) GetLastPostForVideo ¶
func (r *PostRepository) GetLastPostForVideo(ctx context.Context, accountID string, videoID string) (*PostHistory, error)
GetLastPostForVideo retrieves the most recent post of a video to a specific account
func (*PostRepository) GetPostHistoryForAccount ¶
func (r *PostRepository) GetPostHistoryForAccount(ctx context.Context, accountID string, limit int) ([]PostHistory, error)
GetPostHistoryForAccount retrieves post history for a specific account
func (*PostRepository) GetPostStats ¶
func (r *PostRepository) GetPostStats(ctx context.Context) (map[string]interface{}, error)
GetPostStats retrieves posting statistics
func (*PostRepository) GetQueuedPosts ¶
GetQueuedPosts retrieves all posts waiting to be processed
func (*PostRepository) IncrementIterationCount ¶
func (r *PostRepository) IncrementIterationCount(ctx context.Context, postID string) error
IncrementIterationCount increments the iteration counter (Tier 2 validation iterations)
func (*PostRepository) IncrementRetryCount ¶
func (r *PostRepository) IncrementRetryCount(ctx context.Context, postID string) error
IncrementRetryCount increments the retry counter (Tier 1 network retries)
func (*PostRepository) ListByStatus ¶
func (r *PostRepository) ListByStatus(ctx context.Context, status PostStatus) ([]Post, error)
ListByStatus retrieves all posts with a specific status
func (*PostRepository) MarkAsFailed ¶
func (r *PostRepository) MarkAsFailed(ctx context.Context, postID string, status PostStatus, errorMessage string, errorCode string) error
MarkAsFailed marks a post as failed with error details
func (*PostRepository) MarkAsPosted ¶
func (r *PostRepository) MarkAsPosted(ctx context.Context, postID string, platformPostID string, platformURL string) error
MarkAsPosted marks a post as successfully posted
func (*PostRepository) SaveGeneratedMessage ¶
func (r *PostRepository) SaveGeneratedMessage(ctx context.Context, msg *GeneratedMessage) error
SaveGeneratedMessage saves a generated message for debugging
func (*PostRepository) UpdateEngagementMetrics ¶
func (r *PostRepository) UpdateEngagementMetrics(ctx context.Context, historyID string, metrics JSONB) error
UpdateEngagementMetrics updates the engagement metrics for a post
func (*PostRepository) UpdateStatus ¶
func (r *PostRepository) UpdateStatus(ctx context.Context, postID string, status PostStatus) error
UpdateStatus updates the status of a post
func (*PostRepository) UpdateWithMessage ¶
func (r *PostRepository) UpdateWithMessage(ctx context.Context, postID string, messageText string, metadata JSONB) error
UpdateWithMessage updates a post with generated message text
type PostStatus ¶
type PostStatus string
PostStatus represents the lifecycle status of a post
const ( PostStatusQueued PostStatus = "queued" PostStatusGenerating PostStatus = "generating" PostStatusValidating PostStatus = "validating" PostStatusPosting PostStatus = "posting" PostStatusPosted PostStatus = "posted" PostStatusFailedNetwork PostStatus = "failed_network" PostStatusFailedValidation PostStatus = "failed_validation" PostStatusFailedPermanent PostStatus = "failed_permanent" )
type SupabaseConnection ¶
SupabaseConnection represents a connection to Supabase PostgreSQL database
func ConnectSupabase ¶
func ConnectSupabase() (*SupabaseConnection, error)
ConnectSupabase establishes a connection to Supabase PostgreSQL and automatically runs migrations at startup
func (*SupabaseConnection) Close ¶
func (c *SupabaseConnection) Close() error
Close closes the Supabase database connection
func (*SupabaseConnection) HealthCheck ¶
func (c *SupabaseConnection) HealthCheck() error
HealthCheck performs a basic health check on the database
func (*SupabaseConnection) Ping ¶
func (c *SupabaseConnection) Ping() error
Ping verifies the connection to Supabase is alive
type Video ¶
type Video struct {
ID string `db:"id" json:"id"`
VideoID string `db:"video_id" json:"video_id"`
Title string `db:"title" json:"title"`
URL string `db:"url" json:"url"`
ChannelID string `db:"channel_id" json:"channel_id"`
Description *string `db:"description" json:"description,omitempty"`
YouTubeChannelID *string `db:"youtube_channel_id" json:"youtube_channel_id,omitempty"`
ThumbnailURL *string `db:"thumbnail_url" json:"thumbnail_url,omitempty"`
Playlist *string `db:"playlist" json:"playlist,omitempty"`
ConferenceYear *string `db:"conference_year" json:"conference_year,omitempty"`
PresenterTwitter *string `db:"presenter_twitter" json:"presenter_twitter,omitempty"`
PublishedAt *time.Time `db:"published_at" json:"published_at,omitempty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Metadata JSONB `db:"metadata" json:"metadata"`
DurationSeconds *int `db:"duration_seconds" json:"duration_seconds,omitempty"`
ViewCount *int `db:"view_count" json:"view_count,omitempty"`
}
Video represents a YouTube video
type VideoRepository ¶
type VideoRepository struct {
// contains filtered or unexported fields
}
VideoRepository handles all video-related database operations
func NewVideoRepository ¶
func NewVideoRepository(conn *SupabaseConnection) *VideoRepository
NewVideoRepository creates a new VideoRepository
func (*VideoRepository) Count ¶
func (r *VideoRepository) Count(ctx context.Context) (int, error)
Count returns the total number of videos
func (*VideoRepository) Create ¶
func (r *VideoRepository) Create(ctx context.Context, video *Video) error
Create inserts a new video
func (*VideoRepository) GetByVideoID ¶
GetByVideoID retrieves a video by its YouTube video ID
func (*VideoRepository) GetEligibleVideos ¶
func (r *VideoRepository) GetEligibleVideos(ctx context.Context, platformAccountID string) ([]EligibleVideo, error)
GetEligibleVideos retrieves videos eligible for posting to a specific platform account A video is eligible if it hasn't been posted to this account within the cooldown period
func (*VideoRepository) GetRandomEligibleVideo ¶
func (r *VideoRepository) GetRandomEligibleVideo(ctx context.Context, platformAccountID string) (*EligibleVideo, error)
GetRandomEligibleVideo retrieves a random video eligible for posting
func (*VideoRepository) ListAll ¶
func (r *VideoRepository) ListAll(ctx context.Context) ([]Video, error)
ListAll retrieves all videos
func (*VideoRepository) ListByChannel ¶
ListByChannel retrieves all videos for a specific YouTube channel
func (*VideoRepository) Update ¶
func (r *VideoRepository) Update(ctx context.Context, video *Video) error
Update updates an existing video
func (*VideoRepository) VideoExists ¶
VideoExists checks if a video with the given video_id already exists
type YouTubeChannel ¶
type YouTubeChannel struct {
ID string `db:"id" json:"id"`
ChannelID string `db:"channel_id" json:"channel_id"`
RSSFeedURL string `db:"rss_feed_url" json:"rss_feed_url"`
ChannelName *string `db:"channel_name" json:"channel_name,omitempty"`
LastFetchedAt *time.Time `db:"last_fetched_at" json:"last_fetched_at,omitempty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Metadata JSONB `db:"metadata" json:"metadata"`
IsActive bool `db:"is_active" json:"is_active"`
}
YouTubeChannel represents a YouTube channel for video discovery