database

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//AuthorsTable -- author table sql
	AuthorsTable = `
	DROP TABLE IF EXISTS authors;
	
	CREATE TABLE authors (
		id		INTEGER PRIMARY KEY,
		name    TEXT,
		email	TEXT
	);
	`

	//EpisodesTable -- episodes table sql
	EpisodesTable = `` /* 516-byte string literal not displayed */

	//FeedsTable -- feeds table sql
	FeedsTable = `` /* 325-byte string literal not displayed */

	//TagsTable -- tags table sql
	TagsTable = `
	DROP TABLE IF EXISTS tags;
	
	CREATE TABLE tags (
		id		INTEGER PRIMARY KEY,
		name	TEXT NOT NULL UNIQUE
	);
	`

	//FeedsAndTagsTable -- feeds_and_tags table sql
	FeedsAndTagsTable = `` /* 334-byte string literal not displayed */

)

Variables

View Source
var (

	//TestDB -- testing database
	TestDB = fmt.Sprintf("file:%s?_foreign_keys=1", DBPath)
	//DB -- A global reference to the DB
	DB *sql.DB
	//DBPath -- path to test database
	DBPath = filepath.Join(".go-rss-reader", "feeds.db")
)

Functions

func AddAuthor

func AddAuthor(db *sql.DB, name, email string) (int64, error)

AddAuthor -- adds a author to the database

func AddEpisode

func AddEpisode(db *sql.DB, feedID int64, url, title string, date *time.Time, rawData string) (int64, error)

AddEpisode -- adds an episode to the database

func AddFeedFileData

func AddFeedFileData(fileData []file.Data) (map[int64]file.Data, error)

AddFeedFileData -- Adds Feed File Data to the database

func AddFeedURL

func AddFeedURL(db *sql.DB, url string) (int64, error)

AddFeedURL -- Adds a feed url to the database

func AddTag

func AddTag(db *sql.DB, tag string) (int64, error)

AddTag -- Adds a tag to the database

func AddTagToFeed

func AddTagToFeed(db *sql.DB, feedID, tagID int64) (int64, error)

AddTagToFeed -- Adds a Tag to a feed via the feeds_and_tags table

func AllActiveFeedTags

func AllActiveFeedTags(db *sql.DB, feedID int64) map[int64]string

AllActiveFeedTags -- Returns all of the active tags associated with a feed

func AllActiveFeeds

func AllActiveFeeds(db *sql.DB) map[int64]string

AllActiveFeeds -- Returns all active feeds

func AuthorExist

func AuthorExist(db *sql.DB, authorName, authorEmail string) (result bool)

AuthorExist -- Checks to see if an author exists

func Create

func Create(path string) (*sql.DB, error)

Create -- Created the database

func DeleteAllTagsFromFeed

func DeleteAllTagsFromFeed(db *sql.DB, feedID int64) error

DeleteAllTagsFromFeed -- flips the delete flag for all tags associated with a feed

func DeleteFeed

func DeleteFeed(db *sql.DB, feedID int64) error

DeleteFeed -- Flips the delete flag on for a feed in the database

func DeleteTagFromFeed

func DeleteTagFromFeed(db *sql.DB, feedID, tagID int64) error

DeleteTagFromFeed -- Deletes a tag from a feed

func EpisodeExist

func EpisodeExist(db *sql.DB, title string) (result bool)

EpisodeExist -- Based on the title, it checks if that episode already exists

func EpisodeHasAuthor

func EpisodeHasAuthor(db *sql.DB, episodeID int64) (result bool)

EpisodeHasAuthor -- returns true is an author id exists and false otherwise

func EpisodeHasMediaContent

func EpisodeHasMediaContent(db *sql.DB, episodeID int64) (result bool)

EpisodeHasMediaContent -- returns true is an author id exists and false otherwise

func Exist

func Exist(path string) bool

Exist -- checks for the existance of a file

func FeedHasAuthor

func FeedHasAuthor(db *sql.DB, feedID int64) (result bool)

FeedHasAuthor -- returns true is an author id exists and false otherwise

func FeedHasTag

func FeedHasTag(db *sql.DB, feedID, tagID int64) bool

FeedHasTag -- Checks to see if a feed has a specific tag

func FeedURLExist

func FeedURLExist(db *sql.DB, url string) bool

FeedURLExist -- Checks to see if a feed exists

func FilterFeedTags

func FilterFeedTags(db *sql.DB, feedID int64, tags map[int64]string) map[int64]string

FilterFeedTags -- Takes in a map of feed tags and compares them with the tags listed in the database for that feed. Returns all the tags for that feed that are listed as active in the database but where not passed in.

func FilterFeeds

func FilterFeeds(db *sql.DB, feeds map[int64]string) map[int64]string

FilterFeeds -- Takes in a list of feeds and compares them with the feeds listed in the Database. Returns all the feeds that are listed as active in the database but where not in the list.

func FormatEpisodeHeader

func FormatEpisodeHeader(feedName, episodeTitle, author, episodeLink, episodeDate, mediaContent string) (result string)

FormatEpisodeHeader -- formats the episode header

func GetAuthor

func GetAuthor(db *sql.DB, authorID int64) (name string, email string, err error)

GetAuthor -- returns the name and email of the author

func GetAuthorByNameAndEmail

func GetAuthorByNameAndEmail(db *sql.DB, authorName, authorEmail string) (id int64, err error)

GetAuthorByNameAndEmail -- Given a name and email, will return authorID

func GetEpisode

func GetEpisode(db *sql.DB, episodeID int64) (url, title string, date time.Time, seen int64, rawData string, err error)

GetEpisode -- gets an episode from the database

func GetEpisodeAuthor

func GetEpisodeAuthor(db *sql.DB, episodeID int64) (name, email string, err error)

GetEpisodeAuthor -- returns the episode author

func GetEpisodeHeaderData

func GetEpisodeHeaderData(db *sql.DB, feedID, episodeID int64) (feedTitle, episodeTitle, author, episodeLink, dateString, mediaContent string, err error)

GetEpisodeHeaderData -- Gets the infomation needed to create the episode header

func GetEpisodeIDByFeedIDAndTitle

func GetEpisodeIDByFeedIDAndTitle(db *sql.DB, feedID int64, episodeTitle string) (id int64, err error)

GetEpisodeIDByFeedIDAndTitle -- Gets the episodes using feed id and episode title

func GetEpisodeMediaContent

func GetEpisodeMediaContent(db *sql.DB, episodeID int64) (mediaContent string, err error)

GetEpisodeMediaContent -- Gets the episode's media content from the database

func GetFeedAuthor

func GetFeedAuthor(db *sql.DB, feedID int64) (name, email string, err error)

GetFeedAuthor -- returns the feed author

func GetFeedAuthorID

func GetFeedAuthorID(db *sql.DB, feedID int64) (int64, error)

GetFeedAuthorID -- returns the feed's author ID

func GetFeedDataFromSite

func GetFeedDataFromSite(url string) (string, error)

GetFeedDataFromSite -- gets the feed data from the feed url and returns it

func GetFeedEpisodeIDs

func GetFeedEpisodeIDs(db *sql.DB, feedID int64) (ids []int64, err error)

GetFeedEpisodeIDs -- return ???

func GetFeedEpisodeSeenRatio

func GetFeedEpisodeSeenRatio(db *sql.DB, feedID int64) (seen, total int64, err error)

GetFeedEpisodeSeenRatio -- return the seen over total episode seen for a feed.

func GetFeedID

func GetFeedID(db *sql.DB, item string) (int64, error)

GetFeedID -- Given a url or title, it returns the feed id

func GetFeedInfo

func GetFeedInfo(db *sql.DB, feedID int64) (err error)

GetFeedInfo -- Pulls the rss feed from the website and dumps the needed info into the database

func GetFeedRawData

func GetFeedRawData(db *sql.DB, feedID int64) (string, error)

GetFeedRawData -- returns the feed's raw data

func GetFeedTagID

func GetFeedTagID(db *sql.DB, feedID, tagID int64) (int64, error)

GetFeedTagID -- gets the id for a feed tag

func GetFeedTitle

func GetFeedTitle(db *sql.DB, feedID int64) (string, error)

GetFeedTitle -- returns the feed title

func GetFeedURL

func GetFeedURL(db *sql.DB, feedID int64) (url string, err error)

GetFeedURL -- returnd the feed's url

func GetTagID

func GetTagID(db *sql.DB, name string) (int64, error)

GetTagID -- Given a tag name, returns the tag id

func Init

func Init(dsn string, reset bool) (*sql.DB, error)

Init -- Initializes the database. The reset param allows you to recreate the database.

func IsFeedDeleted

func IsFeedDeleted(db *sql.DB, feedID int64) bool

IsFeedDeleted -- Checks to see if the feed is currently marked as deleted

func IsFeedTagDeleted

func IsFeedTagDeleted(db *sql.DB, feedTagID int64) bool

IsFeedTagDeleted -- Checks to see if the feed tag is currently marked as deleted

func MarkEpisodeAsSeen

func MarkEpisodeAsSeen(db *sql.DB, episodeID int64) (err error)

MarkEpisodeAsSeen -- marks and episode as seen

func TagExist

func TagExist(db *sql.DB, tag string) bool

TagExist -- Checks to see if a tag exists

func UndeleteFeed

func UndeleteFeed(db *sql.DB, feedID int64) error

UndeleteFeed -- Flips the delete flag off for a feed in the database

func UndeleteFeedTag

func UndeleteFeedTag(db *sql.DB, feedTagID int64) error

UndeleteFeedTag -- Flips the delete flag off for a feed tag in the database

func UpdateEpisodeAuthor

func UpdateEpisodeAuthor(db *sql.DB, episodeID, authorID int64) (err error)

UpdateEpisodeAuthor -- Updates the author associated with the episode

func UpdateEpisodeMediaContent

func UpdateEpisodeMediaContent(db *sql.DB, episodeID int64, mediaContent string) (err error)

UpdateEpisodeMediaContent -- updates the media content to the database

func UpdateFeedAuthor

func UpdateFeedAuthor(db *sql.DB, feedID, authorID int64) error

UpdateFeedAuthor -- Updates the feed's author

func UpdateFeedRawData

func UpdateFeedRawData(db *sql.DB, feedID int64, rawData string) error

UpdateFeedRawData -- Updates the feed's raw data

func UpdateFeedTitle

func UpdateFeedTitle(db *sql.DB, feedID int64, title string) error

UpdateFeedTitle -- Updates the feed title

Types

type Episode

type Episode struct {
	Feed   string
	Author *gofeed.Person
	Data   *gofeed.Item
}

Episode -- Data structure used to handle each new episode of a feed

type Feed

type Feed struct {
	ID    int64
	URL   string
	Title string
	Tags  []string
	Data  *gofeed.Feed
}

Feed -- Data structure used to hold a feed

func LoadFeed

func LoadFeed(db *sql.DB, id int64) (feed *Feed, err error)

LoadFeed -- Loads a feed from the database

func NewFeed

func NewFeed(id int64, fileData file.Data) (*Feed, error)

NewFeed -- Used to create a new Feed. Id the id is equal to -1, then all of the database interactions will not happen

type Feeds

type Feeds []*Feed

Feeds -- A slice of feeds

func LoadFeeds

func LoadFeeds(db *sql.DB, fileData map[int64]file.Data) (feeds Feeds)

LoadFeeds -- Used to load the feed info from the database

func NewFeeds

func NewFeeds(fileData map[int64]file.Data) (feeds Feeds)

NewFeeds -- Used to create a slice of Feeds

func (Feeds) GuiData

func (f Feeds) GuiData(db *sql.DB) (data []gui.Feed)

GuiData -- The data needed to create the gui interface for feeds

func (Feeds) Len

func (f Feeds) Len() int

Len -- Returns the number of feeds in the slice. Needed for the sort interface.

func (Feeds) Less

func (f Feeds) Less(i, j int) bool

Less -- Does a string comparison on the Title. Needed for the sort interface

func (Feeds) Swap

func (f Feeds) Swap(i, j int)

Swap -- Definining what it means to swap two feeds Needed for the sort interface

Jump to

Keyboard shortcuts

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