store

package
v0.0.0-...-23e6414 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtIter

type ArtIter interface {
	Next() bool
	Article() *Article
	Err() error
	Close() error
}

type Article

type Article struct {
	ID           int    `json:"id,omitempty"`
	CanonicalURL string `json:"canonical_url,omitempty"`
	// all known URLs for article (including canonical)
	// TODO: first url should be considered "preferred" if no canonical?
	URLs     []string `json:"urls,omitempty"`
	Headline string   `json:"headline,omitempty"`
	Authors  []Author `json:"authors,omitempty"`
	Content  string   `json:"content,omitempty"`
	// Published contains date of publication.
	// An ISO8601 string is used instead of time.Time, so that
	// less-precise representations can be held (eg YYYY-MM)
	// If no timezone is given, assume UTC.
	Published   string      `json:"published,omitempty"`
	Updated     string      `json:"updated,omitempty"`
	Publication Publication `json:"publication,omitempty"`
	Keywords    []Keyword   `json:"keywords,omitempty"`
	Section     string      `json:"section,omitempty"`
	// space for extra, free-form data
	//	Extra interface{} `json:"extra,omitempty"`
	// Ha! not free-form any more! (bugfix for annoying int/float json issue)
	Extra *TweetExtra `json:"extra,omitempty"`
}

func ConvertArticle

func ConvertArticle(src *arts.Article) *Article

copy an arts.Article into our struct

type Author

type Author struct {
	Name    string `json:"name"`
	RelLink string `json:"rel_link,omitempty"`
	Email   string `json:"email,omitempty"`
	Twitter string `json:"twitter,omitempty"`
}

type DatePubCount

type DatePubCount struct {
	Date    time.Time
	PubCode string
	Count   int
}

type Filter

type Filter struct {
	// date ranges are [from,to)
	PubFrom   time.Time
	PubTo     time.Time
	AddedFrom time.Time
	AddedTo   time.Time
	// if empty, accept all publications (else only ones in list)
	PubCodes []string
	// exclude any publications in XPubCodes
	XPubCodes []string
	// Only return articles with ID > SinceID
	SinceID int
	// max number of articles wanted
	Count int
}

Filter is a set of params for querying the store

func (*Filter) Describe

func (filt *Filter) Describe() string

Describe returns a concise description of the filter for logging/debugging/whatever

type Keyword

type Keyword struct {
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Publication

type Publication struct {
	Code   string `json:"code"` // short unique code for publication
	Name   string `json:"name,omitempty"`
	Domain string `json:"domain,omitempty"`
}

type Store

type Store interface {
	Close()
	Stash(arts ...*Article) ([]int, error)
	WhichAreNew(artURLs []string) ([]string, error)
	FindURLs(urls []string) ([]int, error)
	FetchCount(filt *Filter) (int, error)
	Fetch(filt *Filter) ArtIter
	FetchPublications() ([]Publication, error)
	FetchSummary(filt *Filter, group string) ([]DatePubCount, error)
	FetchArt(artID int) (*Article, error)
}

type TweetExtra

type TweetExtra struct {
	RetweetCount  int `json:"retweet_count,omitempty"`
	FavoriteCount int `json:"favorite_count,omitempty"`
	// resolved links
	Links []string `json:"links,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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