Documentation
¶
Index ¶
- type Article
- func (a *Article) AddTag(tag string)
- func (a *Article) AddTags(tags ...string)
- func (a *Article) CalculateHash() string
- func (a *Article) GenerateID() string
- func (a *Article) GetMetadata(key string) (interface{}, bool)
- func (a *Article) HasTag(tag string) bool
- func (a *Article) IsRecent(within time.Duration) bool
- func (a *Article) SetMetadata(key string, value interface{})
- func (a *Article) SetSummary(summary string) error
- func (a *Article) String() string
- func (a *Article) SummaryLength() int
- func (a *Article) TitleLength() int
- func (a *Article) UpdateQuality()
- func (a *Article) Validate() error
- type Repository
- func (r *Repository) CalculateHash() string
- func (r *Repository) CalculateTrendScore()
- func (r *Repository) GenerateID() string
- func (r *Repository) GetActivityLevel() string
- func (r *Repository) GetOwner() string
- func (r *Repository) GetPopularityTier() string
- func (r *Repository) GetRepoName() string
- func (r *Repository) HasLanguage() bool
- func (r *Repository) IsPopular() bool
- func (r *Repository) IsRecentlyUpdated(within time.Duration) bool
- func (r *Repository) IsTrending() bool
- func (r *Repository) SetDescription(description string) error
- func (r *Repository) SetLanguage(language string) error
- func (r *Repository) String() string
- func (r *Repository) UpdateStats(stars, forks int, updatedAt time.Time) error
- func (r *Repository) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { // ID is a unique identifier for the article, typically generated from URL or content hash ID string `json:"id" validate:"required"` // Title is the article headline or title Title string `json:"title" validate:"required,min=1,max=500"` // URL is the original article URL URL string `json:"url" validate:"required,url"` // Source identifies the publication or website name Source string `json:"source" validate:"required,min=1,max=100"` // SourceType indicates the collection method: rss, api, or html SourceType string `json:"sourceType" validate:"required,oneof=rss api html"` // PublishedAt is the article publication timestamp PublishedAt time.Time `json:"publishedAt" validate:"required"` // Summary is the article summary or excerpt (50-150 characters recommended) Summary string `json:"summary" validate:"min=10,max=1000"` // Content is the full article text (optional, excluded from JSON by default for size) Content string `json:"content,omitempty"` // Tags are relevant keywords or categories associated with the article Tags []string `json:"tags"` // Relevance score (0.0-1.0) calculated based on content matching Relevance float64 `json:"relevance" validate:"min=0,max=1"` // Quality score (0.0-1.0) based on content completeness and source credibility Quality float64 `json:"quality" validate:"min=0,max=1"` // Metadata contains additional source-specific information Metadata map[string]interface{} `json:"metadata"` }
Article represents a unified data structure for articles from various sources This structure standardizes data from RSS feeds, APIs, and HTML scrapers
func NewArticle ¶
NewArticle creates a new Article instance with required fields and generates ID
func (*Article) CalculateHash ¶
CalculateHash generates a hash for deduplication purposes
func (*Article) GenerateID ¶
GenerateID creates a unique identifier for the article based on URL and title
func (*Article) GetMetadata ¶
GetMetadata retrieves a metadata value by key
func (*Article) IsRecent ¶
IsRecent checks if the article was published within the specified duration
func (*Article) SetMetadata ¶
SetMetadata sets a metadata key-value pair
func (*Article) SetSummary ¶
SetSummary sets the article summary with length validation and optimization
func (*Article) SummaryLength ¶
SummaryLength returns the UTF-8 character count of the summary
func (*Article) TitleLength ¶
TitleLength returns the UTF-8 character count of the title
func (*Article) UpdateQuality ¶
func (a *Article) UpdateQuality()
UpdateQuality recalculates the quality score based on multiple factors
type Repository ¶
type Repository struct { // ID is a unique identifier for the repository, typically generated from FullName ID string `json:"id" validate:"required"` // Name is the repository name (without owner) Name string `json:"name" validate:"required,min=1,max=100"` // FullName is the complete repository identifier including owner (e.g., "owner/repo") FullName string `json:"fullName" validate:"required,min=1,max=200"` // Description is the repository description or summary Description string `json:"description" validate:"max=1000"` // URL is the repository homepage URL URL string `json:"url" validate:"required,url"` // Language is the primary programming language of the repository Language string `json:"language" validate:"max=50"` // Stars is the number of stars/likes the repository has received Stars int `json:"stars" validate:"min=0"` // Forks is the number of times the repository has been forked Forks int `json:"forks" validate:"min=0"` // TrendScore is a calculated score indicating the repository's trending status (0.0-1.0) TrendScore float64 `json:"trendScore" validate:"min=0,max=1"` // UpdatedAt is the timestamp of the last repository update UpdatedAt time.Time `json:"updatedAt" validate:"required"` // Metadata stores additional key-value data for extensibility Metadata map[string]interface{} `json:"metadata,omitempty"` }
Repository represents a unified data structure for code repositories from various sources This structure standardizes data from GitHub API, GitLab API, and other git hosting services
func NewRepository ¶
func NewRepository(name, fullName, url string) *Repository
NewRepository creates a new Repository instance with required fields and generates ID
func (*Repository) CalculateHash ¶
func (r *Repository) CalculateHash() string
CalculateHash generates a hash for deduplication purposes
func (*Repository) CalculateTrendScore ¶
func (r *Repository) CalculateTrendScore()
CalculateTrendScore computes the trending score based on multiple factors
func (*Repository) GenerateID ¶
func (r *Repository) GenerateID() string
GenerateID creates a unique identifier for the repository based on FullName
func (*Repository) GetActivityLevel ¶
func (r *Repository) GetActivityLevel() string
GetActivityLevel returns a string describing the repository's activity level
func (*Repository) GetOwner ¶
func (r *Repository) GetOwner() string
GetOwner extracts the owner name from the FullName (before the slash)
func (*Repository) GetPopularityTier ¶
func (r *Repository) GetPopularityTier() string
GetPopularityTier returns a string describing the repository's popularity tier
func (*Repository) GetRepoName ¶
func (r *Repository) GetRepoName() string
GetRepoName extracts the repository name from the FullName (after the slash)
func (*Repository) HasLanguage ¶
func (r *Repository) HasLanguage() bool
HasLanguage checks if the repository has a specified programming language
func (*Repository) IsPopular ¶
func (r *Repository) IsPopular() bool
IsPopular determines if the repository is considered popular based on stars and forks
func (*Repository) IsRecentlyUpdated ¶
func (r *Repository) IsRecentlyUpdated(within time.Duration) bool
IsRecentlyUpdated checks if the repository was updated within the specified duration
func (*Repository) IsTrending ¶
func (r *Repository) IsTrending() bool
IsTrending determines if the repository is currently trending based on trend score
func (*Repository) SetDescription ¶
func (r *Repository) SetDescription(description string) error
SetDescription sets the repository description with validation
func (*Repository) SetLanguage ¶
func (r *Repository) SetLanguage(language string) error
SetLanguage sets the primary programming language
func (*Repository) String ¶
func (r *Repository) String() string
String returns a string representation of the repository
func (*Repository) UpdateStats ¶
func (r *Repository) UpdateStats(stars, forks int, updatedAt time.Time) error
UpdateStats updates the repository statistics (stars, forks, and last update time)
func (*Repository) Validate ¶
func (r *Repository) Validate() error
Validate performs basic validation on the Repository fields