db

package
v0.0.0-...-56b4c40 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*FeedRuleClient
	// contains filtered or unexported fields
}

Deprecate this and create multiple clients for each table instead.

func NewSqlite3Client

func NewSqlite3Client(dbFile string, showSql bool, logLevel core.LogLevel) (*Client, error)

func (*Client) AddFeed

func (c *Client) AddFeed(source *FeedSource) (int64, error)

func (*Client) AddNews

func (c *Client) AddNews(feedID int64, source *FeedItem) error

func (*Client) CheckWhetherSourceExist

func (c *Client) CheckWhetherSourceExist(url string) (bool, error)

func (*Client) DeleteFeedSource

func (c *Client) DeleteFeedSource(id int64) error

func (*Client) GetActiveFeedSources

func (c *Client) GetActiveFeedSources() ([]*FeedSource, error)

func (*Client) GetActiveFeedSourcesWithStats

func (c *Client) GetActiveFeedSourcesWithStats() ([]*FeedSourceWithUnread, error)

func (*Client) GetAllFeeds

func (c *Client) GetAllFeeds() (res []*FeedSource, err error)

func (*Client) GetFeedItems

func (c *Client) GetFeedItems(id string) (res []*FeedItem, err error)

func (*Client) GetFeedSource

func (c *Client) GetFeedSource(id int64) (*FeedSource, error)

func (*Client) GetNewsItem

func (c *Client) GetNewsItem(id int64) (*FeedItem, error)

func (*Client) ListFeedItems

func (c *Client) ListFeedItems(id string) error

func (*Client) MarkAsRead

func (c *Client) MarkAsRead(newsID int64) error

func (*Client) MarkAsReadMulti

func (c *Client) MarkAsReadMulti(newsID []int64) error

func (*Client) SearchNews

func (c *Client) SearchNews(filters ...Filter) ([]*ExtendedFeedItem, error)

func (*Client) UpdateFeedSource

func (c *Client) UpdateFeedSource(f *FeedSource) error

type DataPoint

type DataPoint struct {
	// auto public key
	Id         int64
	NewsItemId int64 `xorm:"index"`
	Keywords   []string
	Outcome    UserClassification
}

DataPoint for doing our learning

type DataPointClient

type DataPointClient struct {
	Engine *xorm.Engine
}

func (*DataPointClient) GetDataPoint

func (c *DataPointClient) GetDataPoint(newsID int64) (*DataPoint, error)

func (*DataPointClient) GetProcessQueue

func (c *DataPointClient) GetProcessQueue() ([]*ProcessQueue, error)

func (*DataPointClient) MarkAsProcessed

func (c *DataPointClient) MarkAsProcessed(q *ProcessQueue, keywords []string) error

func (*DataPointClient) PopulateProcessQueue

func (c *DataPointClient) PopulateProcessQueue() error

look through datapoints and find news feed that is not a point yet.

func (*DataPointClient) SaveDataPoint

func (c *DataPointClient) SaveDataPoint(point *DataPoint) error

type ExtendedFeedItem

type ExtendedFeedItem struct {
	*FeedItem      `xorm:"extends"`
	IsSaved        bool
	Classification UserClassification
}

feedItem with metadata

func (ExtendedFeedItem) TableName

func (ExtendedFeedItem) TableName() string

type FeedItem

type FeedItem struct {
	// auto public key
	Id     int64
	FeedId int64 `xorm:"index"`
	Read   bool  `xorm:"index"`

	Title       string `xorm:"index"`
	Published   *time.Time
	LinkHref    string `xorm:"unique"`
	Description string
	Content     string
	AuthorName  string
	Category    []string `xorm:"index"`
	Guid        string
	Enclosure   string
	Custom      map[string]string
}

func ToFeedItem

func ToFeedItem(feedID int64, i *gofeed.Item) *FeedItem

type FeedRule

type FeedRule struct {
	FeedId       int64 `xorm:"index"`
	FilterType   RuleType
	FilterAction RuleAction
	FilterString string
}

type FeedRuleClient

type FeedRuleClient struct {
	Engine *xorm.Engine
}

func (*FeedRuleClient) AddRegexRule

func (c *FeedRuleClient) AddRegexRule(feedID int64, regex string, action RuleAction) error

func (*FeedRuleClient) GetRules

func (c *FeedRuleClient) GetRules() ([]*FeedRule, error)

type FeedSource

type FeedSource struct {
	// auto public key
	Id          int64
	Active      bool
	Title       string
	Description string
	UrlSource   string `xorm:"unique"`
	Status      string // TODO
	LastUpdated *time.Time
	LastChecked time.Time
	Created     time.Time `xorm:"created"`
	FavIcon     string
}

type FeedSourceWithUnread

type FeedSourceWithUnread struct {
	*FeedSource `xorm:"extends"`
	UnreadCount int64
	TotalCount  int64
}

TODO comments

func ListAllFeedsWithStats

func ListAllFeedsWithStats(engine *xorm.Engine) ([]*FeedSourceWithUnread, error)

ListAllFeedsWithStatus returns the feeds along with its stats. Note: This can be quite slow.

func (FeedSourceWithUnread) TableName

func (FeedSourceWithUnread) TableName() string

type Filter

type Filter func(s *xorm.Session) *xorm.Session

func FilterFeedID

func FilterFeedID(id int64) Filter

func FilterFeedIds

func FilterFeedIds(feedIDs []int64) Filter

func FilterGUID

func FilterGUID(guid string) Filter

func FilterLimit

func FilterLimit(n int) Filter

func FilterSaved

func FilterSaved() Filter

func FilterUnread

func FilterUnread() Filter

type FlagItemClient

type FlagItemClient struct {
	Engine *xorm.Engine
}

func (*FlagItemClient) FlagItem

func (c *FlagItemClient) FlagItem(newsID int64, feedID int64) (bool, error)

func (*FlagItemClient) GetAllFlagged

func (c *FlagItemClient) GetAllFlagged(feedID int64) ([]int64, error)

func (*FlagItemClient) RemoveFlag

func (c *FlagItemClient) RemoveFlag(newsID int64, feedID int64) (bool, error)

type ProcessQueue

type ProcessQueue struct {
	// auto public key
	Id         int64
	FeedItemId int64 `xorm:"index"`
	NewsItemId int64 `xorm:"index"`
}

type RuleAction

type RuleAction int
const (
	MarkAsRead RuleAction = iota
	Flag
	Delete
	Save
)

type RuleType

type RuleType int
const (
	Regex RuleType = iota
)

type SavedItem

type SavedItem struct {
	FeedItemId int64     `xorm:"pk"`
	NewsItemId int64     `xorm:"pk"`
	Date       time.Time `xorm:"index"`
}

type SavedItemClient

type SavedItemClient struct {
	Engine *xorm.Engine
}

func (*SavedItemClient) RemoveFromSaved

func (c *SavedItemClient) RemoveFromSaved(newsID int64, feedID int64) error

func (*SavedItemClient) Save

func (c *SavedItemClient) Save(newsID int64, feedID int64) error

Save does nothing if the item is already saved.

func (*SavedItemClient) ToggleSave

func (c *SavedItemClient) ToggleSave(newsID int64, feedID int64) (bool, error)

type TagItemClient

type TagItemClient struct {
	Engine *xorm.Engine
}

func (*TagItemClient) SetTags

func (c *TagItemClient) SetTags(feedID int64, newsId int64, tags []string) error

type TaggedItem

type TaggedItem struct {
	FeedId int64    `xorm:"pk"`
	NewsId int64    `xorm:"pk"`
	Tags   []string `xorm:"index"`
}

type UserClassification

type UserClassification int
const (
	NO_DECISION UserClassification = iota
	POSITIVE
	NEGATIVE
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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