repository

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2017 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MaxArticleID int = 1234567890

MaxArticleID is used for sorting descending

Variables

View Source
var ErrArticleNotFound = errors.New("Article not found")

ErrArticleNotFound is returned if an article is not found by id

View Source
var ErrAuthorNotFound = errors.New("Author not found")

ErrAuthorNotFound is returned if an article is not found by id

Functions

This section is empty.

Types

type Repository

type Repository struct {
	Cache  *gocache.Cache
	DB     *gorm.DB
	Logger log.Logger
}

Repository reads from the database or the cache if data is present

func (Repository) FindArticleByID

func (r Repository) FindArticleByID(id int) (*krautreporter.Article, error)

FindArticleByID returns an Article for the ID matching the parameter

func (Repository) FindArticlesOlderThan

func (r Repository) FindArticlesOlderThan(id int, number int) ([]*krautreporter.Article, error)

FindArticlesOlderThan returns a slice of Article that are older than an ID

func (Repository) FindAuthorByID

func (r Repository) FindAuthorByID(id int) (*krautreporter.Author, error)

FindAuthorByID returns an Author for the ID matching the parameter

func (Repository) FindAuthors

func (r Repository) FindAuthors() ([]*krautreporter.Author, error)

FindAuthors returns a slice of all Authors

func (Repository) FindOutdatedArticles

func (r Repository) FindOutdatedArticles() ([]*krautreporter.Article, error)

FindOutdatedArticles returns a slice of Articles that need to be scraped

func (Repository) FindOutdatedAuthors

func (r Repository) FindOutdatedAuthors() ([]*krautreporter.Author, error)

FindOutdatedAuthors returns a slice of Authors that need to be scraped

func (Repository) NextCrawls

func (r Repository) NextCrawls(limit int) ([]*krautreporter.Crawl, error)

NextCrawls gets the next crawls limited by number

func (Repository) SaveAllArticles

func (r Repository) SaveAllArticles(articles []*krautreporter.Article) error

SaveAllArticles takes a slice of Article and saves them to the database

func (Repository) SaveAllAuthors

func (r Repository) SaveAllAuthors(authors []*krautreporter.Author) error

SaveAllAuthors takes a slice of Author and saves them to the database

func (Repository) SaveArticle

func (r Repository) SaveArticle(article *krautreporter.Article) error

SaveArticle takes an Article and saves it to the database

func (Repository) SaveAuthor

func (r Repository) SaveAuthor(author *krautreporter.Author) error

SaveAuthor takes an Author and saves it to the database

Jump to

Keyboard shortcuts

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