feeds

package
v0.0.0-...-df9fb1a Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config            = Configuration{}
	ErrNoDBConnection = errors.New("no database connection")
	ErrNotInCache     = errors.New("no item in cache for this path")
)

Functions

func CreateFeed

func CreateFeed(f Feed) error

func CreateItem

func CreateItem(i Item) error

func DeleteFeed

func DeleteFeed(f Feed) error

func DeleteFeedById

func DeleteFeedById(id uint) error

func FeedExists

func FeedExists(s string) bool

func RecentBreakingNews

func RecentBreakingNews() ([]string, bool)

Returns the last 10 headlines scored 85 or higher

func SaveFeed

func SaveFeed(f Feed) error

func SaveItem

func SaveItem(i Item) error

func UpdateFeeds

func UpdateFeeds() error

LoadFeedsIntoDB loads the feed list from the DB, then calls ingestFromUrlWriteToDB (concurrently) to load all feed items and write them to the DB (skipping duplicates).

Types

type Configuration

type Configuration struct {
	DB            *gorm.DB
	TickerChannel chan Item
}

func (*Configuration) OpenDatabase

func (c *Configuration) OpenDatabase(path string) error

func (*Configuration) SetTickerChannel

func (c *Configuration) SetTickerChannel(ch chan Item)

type Feed

type Feed struct {
	gorm.Model
	Name string
	Abbr string
	Url  string
}

The Feed struct stores information about an RSS feed.

func AllFeeds

func AllFeeds() ([]Feed, error)

type Item

type Item struct {
	ID                 uint `gorm:"primaryKey"`
	CreatedAt          time.Time
	UpdatedAt          time.Time
	Title              string
	FeedAbbr           string
	Link               string
	Description        string
	Content            string
	Hash               string `gorm:"uniqueIndex"`
	BreakingNewsScore  int
	BreakingNewsReason string
	PublishedParsed    *time.Time `gorm:"index"`
}

The Item struct stores an item from an RSS feed.

func FirstUnscoredHeadline

func FirstUnscoredHeadline() (Item, error)

func Items

func Items(filter string, search string, limit int, offset int, timestamp int64) ([]Item, error)

Get items from database. Filter may be "", timestamp may be 0 for all items

func UnscoredHeadlines

func UnscoredHeadlines() ([]Item, error)

Jump to

Keyboard shortcuts

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