db

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrateXSearchRecords

func AutoMigrateXSearchRecords(db *gorm.DB) error

AutoMigrateXSearchRecords creates or updates the necessary database tables for X search records

func SaveXSearchRecords

func SaveXSearchRecords(db *gorm.DB, records []XSearchRecord) error

SaveXSearchRecords saves the prepared X search records to the database

Types

type JSONB

type JSONB map[string]interface{}

JSONB represents a PostgreSQL JSONB column

func (*JSONB) Scan

func (j *JSONB) Scan(value interface{}) error

Scan implements the sql.Scanner interface

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type Video

type Video struct {
	ID      string `json:"ID"`
	HLSURL  string `json:"HLSURL"`
	Preview string `json:"Preview"`
	URL     string `json:"URL"`
}

Video represents a video attachment in a tweet

type XSearchRecord

type XSearchRecord struct {
	gorm.Model
	SearchID       string         `gorm:"index;not null"`         // ID of the scheduled search
	Query          string         `gorm:"not null"`               // Search query used
	TweetID        string         `gorm:"uniqueIndex;not null"`   // Unique ID of the tweet
	UserID         string         `gorm:"index;not null"`         // X user ID who posted
	Username       string         `gorm:"index;not null"`         // X username who posted
	Name           string         `gorm:"not null"`               // Display name of the user
	Text           string         `gorm:"type:text;not null"`     // Tweet content
	HTML           string         `gorm:"type:text"`              // HTML formatted content
	PostedAt       time.Time      `gorm:"index;not null"`         // When tweet was posted
	PermanentURL   string         `gorm:"not null"`               // Permanent link to tweet
	ConversationID string         `gorm:"index"`                  // ID of the conversation thread
	InReplyToID    string         `gorm:"index"`                  // ID of tweet being replied to
	IsReply        bool           `gorm:"not null;default:false"` // Whether tweet is a reply
	IsRetweet      bool           `gorm:"not null;default:false"` // Whether tweet is a retweet
	IsQuoted       bool           `gorm:"not null;default:false"` // Whether tweet is a quote
	IsSelfThread   bool           `gorm:"not null;default:false"` // Whether part of self thread
	IsPin          bool           `gorm:"not null;default:false"` // Whether tweet is pinned
	IsSensitive    bool           `gorm:"not null;default:false"` // Whether content is sensitive
	LikeCount      int            `gorm:"not null;default:0"`     // Number of likes
	RetweetCount   int            `gorm:"not null;default:0"`     // Number of retweets
	ReplyCount     int            `gorm:"not null;default:0"`     // Number of replies
	ViewCount      int            `gorm:"not null;default:0"`     // Number of views
	Hashtags       pq.StringArray `gorm:"type:text[]"`            // Array of hashtags
	URLs           pq.StringArray `gorm:"type:text[]"`            // Array of URLs in tweet
	PhotoURLs      pq.StringArray `gorm:"type:text[]"`            // Array of photo URLs
	VideoURLs      pq.StringArray `gorm:"type:text[]"`            // Array of video URLs
	VideoHLSURLs   pq.StringArray `gorm:"type:text[]"`            // Array of HLS video URLs
	VideoPreviews  pq.StringArray `gorm:"type:text[]"`            // Array of video preview URLs
	GifURLs        pq.StringArray `gorm:"type:text[]"`            // Array of GIF URLs
	Mentions       JSONB          `gorm:"type:jsonb"`             // Full mention data including IDs and names
	Place          JSONB          `gorm:"type:jsonb"`             // Place data if available
	QuotedTweetID  string         `gorm:"index"`                  // ID of quoted tweet
	RetweetedID    string         `gorm:"index"`                  // ID of retweeted tweet
	ThreadID       string         `gorm:"index"`                  // ID of thread if part of one
	Cycle          int            `gorm:"not null"`               // Search cycle number
	SearchedAt     time.Time      `gorm:"index;not null"`         // When search was executed
}

XSearchRecord represents a database record of an X (Twitter) search result from scheduled searches

func PrepareXSearchRecords

func PrepareXSearchRecords(responses []interface{}, searchID string, query string) ([]XSearchRecord, error)

PrepareXSearchRecords converts scheduler search responses into database records

Jump to

Keyboard shortcuts

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