db

package
v0.0.0-...-a0d54a6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package db contains logic for interacting with the database

Index

Constants

View Source
const (
	DatabaseName = "wikifeedia"
)
View Source
const MaxConnections = 256

MaxConnections controls the maximum number of connections for a DB.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Project      string    `json:"project"`
	Article      string    `json:"article"`
	Title        string    `json:"title"`
	ThumbnailURL string    `json:"thumbnail_url"`
	Abstract     string    `json:"abstract"`
	ImageURL     string    `json:"image_url"`
	ArticleURL   string    `json:"article_url"`
	DailyViews   int       `json:"daily_views"`
	Retrieved    time.Time `json:"retrieved"`
}

Article is the data model for a Wikipedia article.

type DB

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

DB is a wrapper around a pgx.ConnPool that knows about the structure of our application schema.

func New

func New(pgurl string) (*DB, error)

New creates a new DB.

func (*DB) DeleteOldArticles

func (db *DB) DeleteOldArticles(
	ctx context.Context, project string, retrievedBefore time.Time,
) error

DeleteOldArticles deletes articles which were retrieved before the specified time.

func (*DB) GetArticles

func (db *DB) GetArticles(
	ctx context.Context, project string, offset, limit int, followerRead bool, asOf string,
) (_ []Article, newAsOf string, _ error)

GetArticles returns the list of articles.

func (*DB) UpsertArticle

func (db *DB) UpsertArticle(ctx context.Context, a Article) error

UpsertArticle upserts a into the database.

Jump to

Keyboard shortcuts

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