dao

package
v0.0.0-...-1fec9c6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ArticleCache *feedCache
)

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword []byte) error

func Client

func Client() *sql.DB

func Close

func Close()

func DeleteSource

func DeleteSource(ctx context.Context, id string) error

func GetAllSources

func GetAllSources(ctx context.Context) ([]domain.Source, error)

func GetAllSourcesForOwner

func GetAllSourcesForOwner(ctx context.Context, ownerID string) ([]domain.Source, error)

func GetArticle

func GetArticle(ctx context.Context, id string) (*domain.Article, error)

func GetArticleByURL

func GetArticleByURL(ctx context.Context, url string) (*domain.Article, error)

func GetArticlesBySourceAndTime

func GetArticlesBySourceAndTime(ctx context.Context, sourceID string, start, end time.Time) ([]domain.Article, error)

func GetArticlesByTime

func GetArticlesByTime(ctx context.Context, start, end time.Time) ([]domain.Article, error)

func GetArticlesForOwner

func GetArticlesForOwner(ctx context.Context, ownerID string, start, end time.Time) ([]domain.Article, []domain.Source, error)

func GetArticlesForSource

func GetArticlesForSource(ctx context.Context, link string) ([]domain.Article, error)

func GetEdition

func GetEdition(ctx context.Context, id string) (*domain.Edition, error)

func GetEditionForTime

func GetEditionForTime(ctx context.Context, t time.Time, allowRecent bool) (*domain.Edition, error)

func GetLastFetchTimeForSource

func GetLastFetchTimeForSource(ctx context.Context, sourceID int) (time.Time, error)

GetLastFetchTimeForSource fetches the last fetch time for a given source from the database

func GetSource

func GetSource(ctx context.Context, id string) (*domain.Source, error)

func GetSources

func GetSources(ctx context.Context, ownerID string) ([]domain.Source, error)

func GetUser

func GetUser(ctx context.Context, id string) (*domain.User, error)

func GetUserByName

func GetUserByName(ctx context.Context, name string) (*domain.User, error)

func HashPassword

func HashPassword(password string) ([]byte, error)

func Init

func Init(ctx context.Context) error

func InitSources

func InitSources(ctx context.Context) error

func SearchInCache

func SearchInCache(ctx context.Context, query string) ([]domain.Article, error)

func SearchInSQLite

func SearchInSQLite(ctx context.Context, query string) ([]domain.Article, error)

func SetArticle

func SetArticle(ctx context.Context, a *domain.Article) error

func SetEdition

func SetEdition(ctx context.Context, e *domain.Edition) error

func SetLastFetchTimeForSource

func SetLastFetchTimeForSource(ctx context.Context, sourceID int, lastFetchTime time.Time) error

SetLastFetchTimeForSource updates the last fetch time for a given source in the database

func SetSource

func SetSource(ctx context.Context, s *domain.Source) error

func SetUser

func SetUser(ctx context.Context, u *domain.User) error

Types

type Analytics

type Analytics struct {
	UserID             string    `db:"user_id"`
	InsertionTimestamp time.Time `db:"insertion_timestamp"`
	Payload            string    `db:"payload"`
}

type Article

type Article struct {
	ID                string    `db:"id"`
	Title             string    `db:"title"`
	Description       string    `db:"description"`
	CompressedContent []byte    `db:"compressed_content"`
	ImageURL          string    `db:"image_url"`
	Link              string    `db:"link"`
	Author            string    `db:"author"`
	SourceID          int64     `db:"source_id"`
	Timestamp         time.Time `db:"timestamp"`
	Ts                string    `db:"ts"`
	Layout            string    `db:"layout"`
}

type Edition

type Edition struct {
	ID         string            `db:"id"`
	Name       string            `db:"name"`
	Date       string            `db:"date"`
	StartTime  time.Time         `db:"start_time"`
	EndTime    time.Time         `db:"end_time"`
	Created    time.Time         `db:"created"`
	Sources    []Source          `db:"sources"`
	Articles   []Article         `db:"articles"`
	Categories []string          `db:"categories"`
	Metadata   map[string]string `db:"metadata"`
}

type Item

type Item struct {
	Value domain.Article
}

type Source

type Source struct {
	ID            string    `db:"id"`
	OwnerID       string    `db:"owner_id"`
	Name          string    `db:"name"`
	URL           string    `db:"url"`
	FeedURL       string    `db:"feed_url"`
	Categories    []string  `db:"categories"`
	DisableFetch  bool      `db:"disable_fetch"`
	LastFetchTime time.Time `db:"last_fetch_time"`
}

type User

type User struct {
	ID           string    `db:"id"`
	Name         string    `db:"name"`
	Created      time.Time `db:"created"`
	PasswordHash []byte    `db:"password_hash"`
	IsAdmin      bool      `db:"is_admin"`
}

Jump to

Keyboard shortcuts

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