structs

package
v0.0.0-...-ff4bf11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CategorySelectColumns string = `` /* 172-byte string literal not displayed */

CategorySelectColumns is used by the database when reading categories

View Source
const FeedSelectColumns string = `` /* 168-byte string literal not displayed */

FeedSelectColumns is used by the database when reading feeds

View Source
const ItemInsertColumns string = `feedid,
key,
title,
url,
content,
timestamp,
commit_timestamp`

ItemInsertColumns are the columns used at insertion time

View Source
const ItemInsertPlaceholders string = "?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP"

ItemInsertPlaceholders are the placeholders used at insertion time

View Source
const ItemSelectColumns string = `
items.id,
items.feedid,
items.title,
items.url,
items.timestamp,
items.read,
items.commit_timestamp`

ItemSelectColumns is used by the database when reading items

Variables

View Source
var CategoryNameRE = regexp.MustCompile(`^[a-z][a-z0-9-]+$`)

CategoryNameRE is the regular expression matching all valid category names

Functions

func ApplyFeedEdit

func ApplyFeedEdit(edit FeedEdit) func(*Feed) EntityUpdate

ApplyFeedEdit returns a mutation function that applies the given edit

func CategoryApplyEdit

func CategoryApplyEdit(edit CategoryEdit) (
	func(*Category) EntityUpdate, error)

CategoryApplyEdit returns a mutation function that applies the given CategoryEdit to a category after validating it.

func FeedMergeGofeed

func FeedMergeGofeed(gfe *gofeed.Feed) func(*Feed) EntityUpdate

FeedMergeGofeed returns a mutation function that merges in updates from the latest fetched version of the feed.

func FeedSetFetchFailed

func FeedSetFetchFailed(t time.Time) func(f *Feed) EntityUpdate

FeedSetFetchFailed is a mutation function that marks a feed as failing

func ItemSetRead

func ItemSetRead(read bool) func(*Item) EntityUpdate

ItemSetRead returns a mutation function that sets an item as read

Types

type Category

type Category struct {
	// contains filtered or unexported fields
}

Category is a grouping of feeds. Feeds can be in at most one category. Categories do not affect the backend at all.

func ScanCategories

func ScanCategories(rows *sql.Rows) ([]*Category, error)

ScanCategories converts multiple rows into categories

func ScanCategory

func ScanCategory(row *sql.Row) (*Category, error)

ScanCategory converts one row into a category

func (*Category) ID

func (c *Category) ID() int64

ID gets the ID

func (*Category) MarshalJSON

func (c *Category) MarshalJSON() ([]byte, error)

MarshalJSON is used by the JSON marshaller

func (*Category) String

func (c *Category) String() string

type CategoryEdit

type CategoryEdit struct {
	// Categories can never be un-disabled
	Disabled   bool    `json:"disabled"`
	Name       *string `json:"name"`
	Title      *string `json:"title"`
	HiddenNav  *bool   `json:"hiddenNav"`
	HiddenMain *bool   `json:"hiddenMain"`
}

CategoryEdit represents new values for a category from a user edit.

type Entity

type Entity interface {
	ID() int64

	String() string
}

Entity is an object that represents a single row in the database

type EntityUpdate

type EntityUpdate struct {
	// contains filtered or unexported fields
}

EntityUpdate holds the SQL needed to update (but not insert) an entity

func CategorySetSortPosition

func CategorySetSortPosition(c *Category, sortPos int64) EntityUpdate

CategorySetSortPosition mutates a category to change the sort position.

func FeedSetFetchSuccess

func FeedSetFetchSuccess(f *Feed) EntityUpdate

FeedSetFetchSuccess return a mutation function that marks a feed as succeeding

func (EntityUpdate) Get

func (eu EntityUpdate) Get() (string, []interface{})

Get returns the contents of the EntityUpdate

func (EntityUpdate) Noop

func (eu EntityUpdate) Noop() bool

Noop returns whether this update is a no-op that should not be written

func (EntityUpdate) String

func (eu EntityUpdate) String() string

type Feed

type Feed struct {
	// contains filtered or unexported fields
}

Feed represents a single RSS feed

func ScanFeed

func ScanFeed(row *sql.Row) (*Feed, error)

ScanFeed converts one row into a feed

func ScanFeeds

func ScanFeeds(rows *sql.Rows) ([]*Feed, error)

ScanFeeds converts multiple rows into feeds

func (*Feed) ID

func (f *Feed) ID() int64

ID gets the ID

func (*Feed) MarshalJSON

func (f *Feed) MarshalJSON() ([]byte, error)

MarshalJSON is used by the JSON marshaller

func (*Feed) String

func (f *Feed) String() string

func (*Feed) Title

func (f *Feed) Title() string

Title gets the Title

func (*Feed) URL

func (f *Feed) URL() string

URL gets the URL

type FeedEdit

type FeedEdit struct {
	CategoryID    *int64  `json:"categoryId"`
	ClearCategory bool    `json:"clearCategory"`
	Disabled      *bool   `json:"disabled"`
	UserTitle     *string `json:"userTitle"`
}

FeedEdit represents new values for a feed from a user edit

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item represents a single entry in an RSS feed

func CreateNewItems

func CreateNewItems(f *Feed, gfItems []*gofeed.Item) []*Item

CreateNewItems creates items without proper IDs, which may be duplicates of Items already present in the database. These should be inserted or ignored into the database then discarded.

func ScanItem

func ScanItem(row *sql.Row) (*Item, error)

ScanItem converts one row into an Item

func ScanItems

func ScanItems(rows *sql.Rows) ([]*Item, error)

ScanItems converts multiple rows into Items

func (*Item) FeedID

func (it *Item) FeedID() int64

FeedID returns the associated Feed's ID

func (*Item) ID

func (it *Item) ID() int64

ID returns the ID

func (*Item) InsertValues

func (it *Item) InsertValues() []interface{}

InsertValues returns the values to be inserted into the database, except for "read" which depends on a config setting.

func (*Item) MarshalJSON

func (it *Item) MarshalJSON() ([]byte, error)

MarshalJSON is used by the JSON marshaller Content is excluded and must be fetched separately to cut down on data

func (*Item) String

func (it *Item) String() string

func (*Item) URL

func (it *Item) URL() string

URL returns the URL

Jump to

Keyboard shortcuts

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